diff --git a/.travis.yml b/.travis.yml
index 2f79011d3a..d47e98f799 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,7 +29,7 @@ android:
before_script:
- export GRADLE_OPTS="-XX:MaxPermSize=2048m -Xmx1536m"
-script: ./gradlew cleanJar clean testDevDebug assembleDevDebug -PdisablePreDex
+script: ./gradlew cleanJar clean testDebug assembleDebug -PdisablePreDex
after_success:
- chmod a+x .utility/push-docs-to-gh-pages.sh
diff --git a/ServiceApp/art/ic_launcher.svg b/ClientLib/art/ic_launcher.svg
similarity index 100%
rename from ServiceApp/art/ic_launcher.svg
rename to ClientLib/art/ic_launcher.svg
diff --git a/ServiceApp/art/ic_stat_notify.svg b/ClientLib/art/ic_stat_notify.svg
similarity index 100%
rename from ServiceApp/art/ic_stat_notify.svg
rename to ClientLib/art/ic_stat_notify.svg
diff --git a/ClientLib/build.gradle b/ClientLib/build.gradle
index cf8f19aeeb..6144eea16c 100644
--- a/ClientLib/build.gradle
+++ b/ClientLib/build.gradle
@@ -1,8 +1,9 @@
apply plugin: 'com.android.library'
+apply plugin: 'com.getkeepsafe.dexcount'
ext {
- VERSION_MAJOR = 2
- VERSION_MINOR = 9
+ VERSION_MAJOR = 3
+ VERSION_MINOR = 0
VERSION_PATCH = 1
VERSION_SUFFIX = "release"
@@ -10,19 +11,40 @@ ext {
PUBLISH_VERSION = generateVersionName("", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_SUFFIX)
PUBLISH_VERSION_CODE = computeVersionCode(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
PROJECT_DESCRIPTION = "Android DroneKit client library."
- PROJECT_LABELS = ['3DR', '3DR Services', 'DroneAPI', 'Android', 'DroneKit']
- PROJECT_LICENSES = ['Apache-2.0']
+ PROJECT_LABELS = ['DroneCode', '3DR', 'Tower', 'DroneAPI', 'Android', 'DroneKit', '3DR Services']
+ PROJECT_LICENSE = 'The Apache Software License, Version 2.0'
+ PROJECT_LICENSE_URL = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ PROJECT_LICENSE_DISTRIBUTION = 'repo'
}
+//Log levels values
+def logLevelVerbose = 2;
+def logLevelDebug = 3;
+def logLevelInfo = 4;
+def logLevelWarn = 5;
+def logLevelError = 6;
+def logLevelAssert = 7;
+
android {
compileSdkVersion android_build_sdk_version
buildToolsVersion android_build_tools_version
+ dexOptions {
+ javaMaxHeapSize "4g"
+ }
+
defaultConfig {
minSdkVersion android_build_min_sdk_version
targetSdkVersion android_build_target_sdk_version
+
versionCode PUBLISH_VERSION_CODE
versionName PUBLISH_VERSION
+
+ //Build config fields
+ buildConfigField "boolean", "SITL_DEBUG", "false"
+ buildConfigField "String", "SOLO_LINK_IP", getSoloLinkIp()
+ buildConfigField "boolean", "WRITE_LOG_FILE", "false"
+ buildConfigField "int", "LOG_FILE_LEVEL", "$logLevelDebug"
}
sourceSets {
@@ -52,16 +74,67 @@ android {
}
}
}
+
+ buildTypes {
+ debug {
+ debuggable true
+ buildConfigField "boolean", "WRITE_LOG_FILE", "true"
+ }
+
+ sitl {
+ debuggable true
+ buildConfigField "String", "SOLO_LINK_IP", getLocalIp()
+ buildConfigField "boolean", "SITL_DEBUG", "true"
+ }
+
+ release {
+ }
+ }
+
+ testOptions {
+ unitTests.returnDefaultValues = true
+ }
}
dependencies {
- compile "com.android.support:support-v4:${support_lib_version}"
+ compile 'com.jakewharton.timber:timber:3.1.0'
+
compile "com.google.android.gms:play-services-base:${play_services_version}"
+ compile "com.google.android.gms:play-services-location:${play_services_version}"
+
+ //Java semver library
+ compile 'com.github.zafarkhaja:java-semver:0.9.0'
+
+ compile 'com.jcraft:jsch:0.1.51'
+
+ //MP4 generation library
+ compile 'com.googlecode.mp4parser:isoparser:1.1.7'
+
+ compile 'org.droidplanner.android:usb-serial-android:0.1.0'
debugCompile project(':Mavlink')
- releaseCompile files('libs/Mavlink.jar')
+// sitlCompile project(':Mavlink')
+
+ compile files('libs/Mavlink.jar')
+ compile files('libs/d2xx.jar')
+
+ androidTestCompile 'junit:junit:4.12'
+ androidTestCompile "org.robolectric:robolectric:3.0"
+}
+
+def getSoloLinkIp() {
+ return '\"10.1.1.10\"'
+}
+
+def getLocalIp() {
+ try {
+ return '\"' + InetAddress.getLocalHost().getCanonicalHostName() + '\"'
+ }catch(Exception e){
+ return '\"\"'
+ }
}
+evaluationDependsOn ':Mavlink'
assemble.dependsOn ':Mavlink:jar'
-apply from: "../release_android_library.gradle"
\ No newline at end of file
+apply from: "$projectDir/maven-push.gradle"
\ No newline at end of file
diff --git a/ServiceApp/libs/d2xx.jar b/ClientLib/libs/d2xx.jar
similarity index 100%
rename from ServiceApp/libs/d2xx.jar
rename to ClientLib/libs/d2xx.jar
diff --git a/ClientLib/maven-push.gradle b/ClientLib/maven-push.gradle
new file mode 100644
index 0000000000..cdacd69277
--- /dev/null
+++ b/ClientLib/maven-push.gradle
@@ -0,0 +1,128 @@
+apply plugin: 'maven'
+apply plugin: 'signing'
+
+def projectGroupId = 'com.o3dr.android'
+def projectArtifactId = project.PUBLISH_ARTIFACT_ID
+def projectVersion = project.PUBLISH_VERSION
+def projectDescription = project.PROJECT_DESCRIPTION
+def projectLabels = project.PROJECT_LABELS
+def projectLicense = project.PROJECT_LICENSE
+def projectLicenseUrl = project.PROJECT_LICENSE_URL
+def projectLicenseDistribution = project.PROJECT_LICENSE_DISTRIBUTION
+
+def getMavenOrg(){
+ return hasProperty('COM_O3DR_MAVEN_ORG') ? COM_O3DR_MAVEN_ORG : ''
+}
+
+def getMavenPublishUrl(String artifactId){
+ def prefix = hasProperty('COM_O3DR_MAVEN_PUBLISH_URL_PREFIX') ? COM_O3DR_MAVEN_PUBLISH_URL_PREFIX : null
+ if(prefix == null)
+ return null
+
+ return "$prefix/$artifactId/;publish=0;override=1"
+}
+
+def getMavenPomPackaging(){
+ return hasProperty('COM_O3DR_MAVEN_POM_PACKAGING') ? COM_O3DR_MAVEN_POM_PACKAGING : 'aar'
+}
+
+def getDeveloperId(){
+ return hasProperty('DEVELOPER_ID') ? DEVELOPER_ID : ''
+}
+
+def getDeveloperName(){
+ return hasProperty('DEVELOPER_NAME') ? DEVELOPER_NAME : ''
+}
+
+afterEvaluate { project ->
+ uploadArchives {
+ repositories {
+ mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+
+ pom.groupId = projectGroupId
+ pom.artifactId = projectArtifactId
+ pom.version = projectVersion
+
+ repository(url: getMavenPublishUrl(projectArtifactId)) {
+ authentication(userName: getMavenUsername(), password: getMavenApiKey())
+ }
+
+ pom.project {
+ name projectArtifactId
+ packaging getMavenPomPackaging()
+ description projectDescription
+
+ url 'https://github.com/dronekit/dronekit-android'
+ scm {
+ url 'https://github.com/dronekit/dronekit-android'
+ connection 'scm:git:git@github.com:dronekit/dronekit-android.git'
+ developerConnection 'scm:git:git@github.com:dronekit/dronekit-android.git'
+ }
+
+ licenses {
+ license {
+ name projectLicense
+ url projectLicenseUrl
+ distribution projectLicenseDistribution
+ }
+ }
+
+ developers {
+ developer {
+ id getDeveloperId()
+ name getDeveloperName()
+ }
+ }
+ }
+ }
+ }
+ }
+
+ signing {
+ required { gradle.taskGraph.hasTask("uploadArchives") }
+ sign configurations.archives
+ }
+
+ task androidJavadocs(type: Javadoc) {
+ failOnError false
+
+ //Add the project java source directory.
+ def files = [android.sourceSets.main.java.srcDirs]
+
+ //Add the java source directories for the project's dependencies
+ configurations.compile.dependencies.each {
+ if (it instanceof ProjectDependency) {
+ def dependency = it as ProjectDependency
+ def depProj = dependency.getDependencyProject()
+ def projName = depProj.getName()
+ if(projName != "Mavlink") {
+ files += depProj.android.sourceSets.main.java.srcDirs
+ }
+ }
+ }
+
+ source = files
+ title = projectDescription
+ exclude '**/*.aidl', 'org/droidplanner/services/android/impl/**'
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ options.links("http://docs.oracle.com/javase/7/docs/api/")
+ options.links("https://developer.android.com/reference/packages.html")
+ }
+
+ task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs){
+ classifier = 'javadoc'
+ from androidJavadocs.destinationDir
+ }
+
+ task androidSourcesJar(type: Jar){
+ classifier = 'sources'
+ from android.sourceSets.main.java.srcDirs
+ exclude 'org/droidplanner/services/android/impl/**'
+ }
+
+ artifacts {
+ archives androidSourcesJar
+ archives androidJavadocsJar
+ }
+}
\ No newline at end of file
diff --git a/ServiceApp/test/java/com/o3dr/android/client/apis/ControlApiTest.java b/ClientLib/src/androidTest/java/com/o3dr/android/client/apis/ControlApiTest.java
similarity index 96%
rename from ServiceApp/test/java/com/o3dr/android/client/apis/ControlApiTest.java
rename to ClientLib/src/androidTest/java/com/o3dr/android/client/apis/ControlApiTest.java
index c2cb9ada0f..5b0203af76 100644
--- a/ServiceApp/test/java/com/o3dr/android/client/apis/ControlApiTest.java
+++ b/ClientLib/src/androidTest/java/com/o3dr/android/client/apis/ControlApiTest.java
@@ -7,8 +7,9 @@
import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.mock.MockDrone;
-import org.junit.Assert;
+import junit.framework.Assert;
+
+import org.droidplanner.services.android.impl.mock.MockDrone;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
@@ -24,7 +25,7 @@
* Created by Fredia Huya-Kouadio on 10/23/15.
*/
@RunWith(RobolectricGradleTestRunner.class)
-@Config(constants = org.droidplanner.services.android.BuildConfig.class, sdk = 18)
+@Config(constants = com.o3dr.android.client.BuildConfig.class, sdk = 18)
public class ControlApiTest {
private static final SparseArray expectedVelocitiesPerAttitude = new SparseArray<>();
diff --git a/ServiceApp/test/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/TLVMessageParserTest.java b/ClientLib/src/androidTest/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/TLVMessageParserTest.java
similarity index 100%
rename from ServiceApp/test/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/TLVMessageParserTest.java
rename to ClientLib/src/androidTest/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/TLVMessageParserTest.java
diff --git a/ServiceApp/test/java/com/o3dr/services/android/lib/util/MathUtilsTest.java b/ClientLib/src/androidTest/java/com/o3dr/services/android/lib/util/MathUtilsTest.java
similarity index 100%
rename from ServiceApp/test/java/com/o3dr/services/android/lib/util/MathUtilsTest.java
rename to ClientLib/src/androidTest/java/com/o3dr/services/android/lib/util/MathUtilsTest.java
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/BasicTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/BasicTest.java
similarity index 80%
rename from ServiceApp/test/java/org/droidplanner/services/android/BasicTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/BasicTest.java
index cc6a50e20a..313f94a605 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/BasicTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/BasicTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android;
+package org.droidplanner.services.android.impl;
import android.content.Context;
import android.os.Bundle;
@@ -8,25 +8,28 @@
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.common.msg_command_long;
import com.MAVLink.enums.MAV_CMD;
+import com.o3dr.android.client.BuildConfig;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduCopter;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.mock.MockMAVLinkClient;
-import org.droidplanner.services.android.utils.AndroidApWarningParser;
import org.junit.Assert;
import org.junit.Before;
+
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduCopter;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.mock.MockMAVLinkClient;
+import org.droidplanner.services.android.impl.utils.AndroidApWarningParser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+
/**
* Created by djmedina on 3/5/15.
* This is a simple test case.
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilotTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilotTest.java
similarity index 96%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilotTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilotTest.java
index aa26a0f7d4..2a7daa2fa0 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilotTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilotTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm;
import com.github.zafarkhaja.semver.Version;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord2DTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord2DTest.java
similarity index 81%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord2DTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord2DTest.java
index 392967e3ab..74bde32af0 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord2DTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord2DTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.coordinates;
+package org.droidplanner.services.android.impl.core.helpers.coordinates;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord3DTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord3DTest.java
similarity index 94%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord3DTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord3DTest.java
index d8c25059ac..c535556833 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/Coord3DTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/Coord3DTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.coordinates;
+package org.droidplanner.services.android.impl.core.helpers.coordinates;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/CoordBoundsTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBoundsTest.java
similarity index 94%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/CoordBoundsTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBoundsTest.java
index 5cde695c93..ec87117274 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/coordinates/CoordBoundsTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBoundsTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.coordinates;
+package org.droidplanner.services.android.impl.core.helpers.coordinates;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/geoTools/GeoToolsTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoToolsTest.java
similarity index 93%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/helpers/geoTools/GeoToolsTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoToolsTest.java
index 41cd080e82..9e45ebcf2b 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/geoTools/GeoToolsTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoToolsTest.java
@@ -1,11 +1,12 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.polygon.Polygon;
+import org.droidplanner.services.android.impl.core.polygon.Polygon;
+
public class GeoToolsTest extends TestCase {
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/units/AreaTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/units/AreaTest.java
similarity index 92%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/helpers/units/AreaTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/units/AreaTest.java
index 5476372415..685d4f711f 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/helpers/units/AreaTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/helpers/units/AreaTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.units;
+package org.droidplanner.services.android.impl.core.helpers.units;
import junit.framework.TestCase;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeCameraTriggerImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeCameraTriggerImplTest.java
similarity index 59%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeCameraTriggerImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeCameraTriggerImplTest.java
index d354c433b3..6900de0e27 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeCameraTriggerImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeCameraTriggerImplTest.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.commands.CameraTriggerImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.CameraTriggerImpl;
import java.util.List;
public class ChangeCameraTriggerImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- CameraTriggerImpl item = new CameraTriggerImpl(mission, (12.0));
+ MissionImpl missionImpl = new MissionImpl(null);
+ CameraTriggerImpl item = new CameraTriggerImpl(missionImpl, (12.0));
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeSpeedImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeSpeedImplTest.java
similarity index 67%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeSpeedImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeSpeedImplTest.java
index b5b6fbe13c..48958226f4 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ChangeSpeedImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ChangeSpeedImplTest.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.commands.ChangeSpeedImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ChangeSpeedImpl;
import java.util.List;
public class ChangeSpeedImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- ChangeSpeedImpl item = new ChangeSpeedImpl(mission, 12.0);
+ MissionImpl missionImpl = new MissionImpl(null);
+ ChangeSpeedImpl item = new ChangeSpeedImpl(missionImpl, 12.0);
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ConditionYawImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ConditionYawImplTest.java
similarity index 63%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ConditionYawImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ConditionYawImplTest.java
index aa28ddc4ad..5dfba2860b 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/ConditionYawImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/ConditionYawImplTest.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.commands.ConditionYawImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ConditionYawImpl;
import java.util.List;
public class ConditionYawImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- ConditionYawImpl item = new ConditionYawImpl(mission, 12, false);
+ MissionImpl missionImpl = new MissionImpl(null);
+ ConditionYawImpl item = new ConditionYawImpl(missionImpl, 12, false);
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/LandImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImplTest.java
similarity index 71%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/LandImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImplTest.java
index 8b062c8b4e..e93df02557 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/LandImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImplTest.java
@@ -1,19 +1,19 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
import java.util.List;
public class LandImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- LandImpl item = new LandImpl(mission);
+ MissionImpl missionImpl = new MissionImpl(null);
+ LandImpl item = new LandImpl(missionImpl);
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItemTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItemTest.java
similarity index 66%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItemTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItemTest.java
index dc2c54593e..7ebed0749d 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItemTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItemTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_FRAME;
@@ -6,13 +6,13 @@
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
public class SpatialCoordItemTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- WaypointImpl item = new WaypointImpl(mission, new LatLongAlt(0.1, 1, (2)));
+ MissionImpl missionImpl = new MissionImpl(null);
+ WaypointImpl item = new WaypointImpl(missionImpl, new LatLongAlt(0.1, 1, (2)));
msg_mission_item mavMsg = item.packMissionItem().get(0);
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/TakeoffImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/TakeoffImplTest.java
similarity index 65%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/TakeoffImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/TakeoffImplTest.java
index 31c8e126c2..bc1a773c5f 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/TakeoffImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/TakeoffImplTest.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.commands.TakeoffImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.TakeoffImpl;
import java.util.List;
public class TakeoffImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- TakeoffImpl item = new TakeoffImpl(mission, (50.0));
+ MissionImpl missionImpl = new MissionImpl(null);
+ TakeoffImpl item = new TakeoffImpl(missionImpl, (50.0));
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/WaypointImplTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImplTest.java
similarity index 70%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/WaypointImplTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImplTest.java
index 12c3e955be..23665b1e05 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/mission/waypoints/WaypointImplTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImplTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
@@ -6,15 +6,15 @@
import junit.framework.TestCase;
-import org.droidplanner.services.android.core.mission.Mission;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
import java.util.List;
public class WaypointImplTest extends TestCase {
public void testPackMissionItem() {
- Mission mission = new Mission(null);
- WaypointImpl item = new WaypointImpl(mission, new LatLongAlt(0, 1, (2)));
+ MissionImpl missionImpl = new MissionImpl(null);
+ WaypointImpl item = new WaypointImpl(missionImpl, new LatLongAlt(0, 1, (2)));
List listOfMsg = item.packMissionItem();
assertEquals(1, listOfMsg.size());
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/core/survey/FootprintTest.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/survey/FootprintTest.java
similarity index 97%
rename from ServiceApp/test/java/org/droidplanner/services/android/core/survey/FootprintTest.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/survey/FootprintTest.java
index a5621dbb3a..2e0327bb55 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/core/survey/FootprintTest.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/core/survey/FootprintTest.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.survey;
+package org.droidplanner.services.android.impl.core.survey;
import com.MAVLink.ardupilotmega.msg_camera_feedback;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/mock/MockDrone.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockDrone.java
similarity index 86%
rename from ServiceApp/test/java/org/droidplanner/services/android/mock/MockDrone.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockDrone.java
index 7e03e2dd93..55fe2d5c33 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/mock/MockDrone.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockDrone.java
@@ -1,11 +1,9 @@
-package org.droidplanner.services.android.mock;
+package org.droidplanner.services.android.impl.mock;
import android.content.Context;
import android.os.Parcelable;
import com.o3dr.android.client.Drone;
-import com.o3dr.services.android.lib.drone.attribute.AttributeType;
-import com.o3dr.services.android.lib.drone.property.Attitude;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
import com.o3dr.services.android.lib.model.action.Action;
diff --git a/ServiceApp/test/java/org/droidplanner/services/android/mock/MockMAVLinkClient.java b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockMAVLinkClient.java
similarity index 78%
rename from ServiceApp/test/java/org/droidplanner/services/android/mock/MockMAVLinkClient.java
rename to ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockMAVLinkClient.java
index 8373e3182b..21a36c1c94 100644
--- a/ServiceApp/test/java/org/droidplanner/services/android/mock/MockMAVLinkClient.java
+++ b/ClientLib/src/androidTest/java/org/droidplanner/services/android/impl/mock/MockMAVLinkClient.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.mock;
+package org.droidplanner.services.android.impl.mock;
import android.content.Context;
@@ -7,8 +7,9 @@
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.communication.service.MAVLinkClient;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.communication.service.MAVLinkClient;
+
/**
* Created by Fredia Huya-Kouadio on 12/17/15.
diff --git a/ClientLib/src/main/AndroidManifest.xml b/ClientLib/src/main/AndroidManifest.xml
index df1ff90a7e..bc14e62699 100644
--- a/ClientLib/src/main/AndroidManifest.xml
+++ b/ClientLib/src/main/AndroidManifest.xml
@@ -3,13 +3,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:excludeFromRecents="true">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ServiceApp/assets/CameraInfo/Canon A2300 A2400.xml b/ClientLib/src/main/assets/CameraInfo/Canon A2300 A2400.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon A2300 A2400.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon A2300 A2400.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon ELPH 110 320 HS.xml b/ClientLib/src/main/assets/CameraInfo/Canon ELPH 110 320 HS.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon ELPH 110 320 HS.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon ELPH 110 320 HS.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon ELPH 115 130 IS.xml b/ClientLib/src/main/assets/CameraInfo/Canon ELPH 115 130 IS.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon ELPH 115 130 IS.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon ELPH 115 130 IS.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon ELPH 330 HS.xml b/ClientLib/src/main/assets/CameraInfo/Canon ELPH 330 HS.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon ELPH 330 HS.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon ELPH 330 HS.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon ELPH 520 HS.xml b/ClientLib/src/main/assets/CameraInfo/Canon ELPH 520 HS.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon ELPH 520 HS.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon ELPH 520 HS.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon S100.xml b/ClientLib/src/main/assets/CameraInfo/Canon S100.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon S100.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon S100.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon S110 S120.xml b/ClientLib/src/main/assets/CameraInfo/Canon S110 S120.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon S110 S120.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon S110 S120.xml
diff --git a/ServiceApp/assets/CameraInfo/Canon SX260.xml b/ClientLib/src/main/assets/CameraInfo/Canon SX260.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Canon SX260.xml
rename to ClientLib/src/main/assets/CameraInfo/Canon SX260.xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro Hero 3+ Black.xml b/ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Black.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro Hero 3+ Black.xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Black.xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro Hero 3+ Silver (Medium).xml b/ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Silver (Medium).xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro Hero 3+ Silver (Medium).xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Silver (Medium).xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro Hero 3+ Silver (Wide).xml b/ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Silver (Wide).xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro Hero 3+ Silver (Wide).xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ Silver (Wide).xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro Hero 3+ White.xml b/ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ White.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro Hero 3+ White.xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro Hero 3+ White.xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro Hero 4 Black.xml b/ClientLib/src/main/assets/CameraInfo/GoPro Hero 4 Black.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro Hero 4 Black.xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro Hero 4 Black.xml
diff --git a/ServiceApp/assets/CameraInfo/GoPro_Hero_3_Silver.xml b/ClientLib/src/main/assets/CameraInfo/GoPro_Hero_3_Silver.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/GoPro_Hero_3_Silver.xml
rename to ClientLib/src/main/assets/CameraInfo/GoPro_Hero_3_Silver.xml
diff --git a/ServiceApp/assets/CameraInfo/Mobius_A_Lens.xml b/ClientLib/src/main/assets/CameraInfo/Mobius_A_Lens.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Mobius_A_Lens.xml
rename to ClientLib/src/main/assets/CameraInfo/Mobius_A_Lens.xml
diff --git a/ServiceApp/assets/CameraInfo/Mobius_B_Lens.xml b/ClientLib/src/main/assets/CameraInfo/Mobius_B_Lens.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Mobius_B_Lens.xml
rename to ClientLib/src/main/assets/CameraInfo/Mobius_B_Lens.xml
diff --git a/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_Monochrome.xml b/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_Monochrome.xml
new file mode 100644
index 0000000000..000da1d98c
--- /dev/null
+++ b/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_Monochrome.xml
@@ -0,0 +1,8 @@
+
+
+ Parrot Sequoia Monochrome
+ 4.8
+ 3.6
+ 3.98
+ 1.23
+
diff --git a/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_RGB.xml b/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_RGB.xml
new file mode 100644
index 0000000000..70d6f00f34
--- /dev/null
+++ b/ClientLib/src/main/assets/CameraInfo/Parrot_Sequoia_RGB.xml
@@ -0,0 +1,8 @@
+
+
+ Parrot Sequoia RGB
+ 6.17
+ 4.63
+ 4.88
+ 15.9
+
\ No newline at end of file
diff --git a/ServiceApp/assets/CameraInfo/Sentek GEMS V0.xml b/ClientLib/src/main/assets/CameraInfo/Sentek GEMS V0.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sentek GEMS V0.xml
rename to ClientLib/src/main/assets/CameraInfo/Sentek GEMS V0.xml
diff --git a/ServiceApp/assets/CameraInfo/Sentek GEMS V1.xml b/ClientLib/src/main/assets/CameraInfo/Sentek GEMS V1.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sentek GEMS V1.xml
rename to ClientLib/src/main/assets/CameraInfo/Sentek GEMS V1.xml
diff --git a/ServiceApp/assets/CameraInfo/Sentek GEMS V2.xml b/ClientLib/src/main/assets/CameraInfo/Sentek GEMS V2.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sentek GEMS V2.xml
rename to ClientLib/src/main/assets/CameraInfo/Sentek GEMS V2.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony NEX5 16mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony NEX5 16mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony NEX5 16mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony NEX5 16mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony NEX5 20mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony NEX5 20mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony NEX5 20mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony NEX5 20mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony NEX5 25mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony NEX5 25mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony NEX5 25mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony NEX5 25mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony QX1 16mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony QX1 16mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony QX1 16mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony QX1 16mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony QX1 20mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony QX1 20mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony QX1 20mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony QX1 20mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony RX100 M3 24mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony RX100 M3 24mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony RX100 M3 24mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony RX100 M3 24mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony RX100 M3 70mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony RX100 M3 70mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony RX100 M3 70mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony RX100 M3 70mm.xml
diff --git a/ServiceApp/assets/CameraInfo/Sony RX100_M3 50mm.xml b/ClientLib/src/main/assets/CameraInfo/Sony RX100_M3 50mm.xml
similarity index 100%
rename from ServiceApp/assets/CameraInfo/Sony RX100_M3 50mm.xml
rename to ClientLib/src/main/assets/CameraInfo/Sony RX100_M3 50mm.xml
diff --git a/ServiceApp/assets/Parameters/ParameterMetaData.xml b/ClientLib/src/main/assets/Parameters/ParameterMetaData.xml
similarity index 100%
rename from ServiceApp/assets/Parameters/ParameterMetaData.xml
rename to ClientLib/src/main/assets/Parameters/ParameterMetaData.xml
diff --git a/ServiceApp/assets/VehicleProfiles/ArduCopter.xml b/ClientLib/src/main/assets/VehicleProfiles/ArduCopter.xml
similarity index 100%
rename from ServiceApp/assets/VehicleProfiles/ArduCopter.xml
rename to ClientLib/src/main/assets/VehicleProfiles/ArduCopter.xml
diff --git a/ServiceApp/assets/VehicleProfiles/ArduPlane.xml b/ClientLib/src/main/assets/VehicleProfiles/ArduPlane.xml
similarity index 100%
rename from ServiceApp/assets/VehicleProfiles/ArduPlane.xml
rename to ClientLib/src/main/assets/VehicleProfiles/ArduPlane.xml
diff --git a/ServiceApp/assets/VehicleProfiles/ArduRover.xml b/ClientLib/src/main/assets/VehicleProfiles/ArduRover.xml
similarity index 100%
rename from ServiceApp/assets/VehicleProfiles/ArduRover.xml
rename to ClientLib/src/main/assets/VehicleProfiles/ArduRover.xml
diff --git a/ServiceApp/assets/VehicleProfiles/ArduSolo.xml b/ClientLib/src/main/assets/VehicleProfiles/ArduSolo.xml
similarity index 100%
rename from ServiceApp/assets/VehicleProfiles/ArduSolo.xml
rename to ClientLib/src/main/assets/VehicleProfiles/ArduSolo.xml
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/ApiAvailability.java b/ClientLib/src/main/java/com/o3dr/android/client/ApiAvailability.java
new file mode 100644
index 0000000000..ef3421c0c6
--- /dev/null
+++ b/ClientLib/src/main/java/com/o3dr/android/client/ApiAvailability.java
@@ -0,0 +1,72 @@
+package com.o3dr.android.client;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+
+import com.o3dr.services.android.lib.model.IDroidPlannerServices;
+import com.o3dr.services.android.lib.util.version.VersionUtils;
+
+import org.droidplanner.services.android.impl.api.DroidPlannerService;
+
+import java.util.List;
+
+/**
+ * Helper class to verify that the DroneKit-Android services APK is available and up-to-date
+ * Created by Fredia Huya-Kouadio on 7/7/15.
+ */
+class ApiAvailability {
+
+ private static class LazyHolder {
+ private static final ApiAvailability INSTANCE = new ApiAvailability();
+ }
+
+ private static final String SERVICES_CLAZZ_NAME = IDroidPlannerServices.class.getName();
+ private static final String METADATA_KEY = "com.o3dr.dronekit.android.core.version";
+
+ private static final int INVALID_LIB_VERSION = -1;
+
+ //Private to prevent instantiation
+ private ApiAvailability() {
+ }
+
+ static ApiAvailability getInstance() {
+ return LazyHolder.INSTANCE;
+ }
+
+ /**
+ * Find and returns the most adequate instance of the services lib.
+ *
+ * @param context Application context. Must not be null.
+ * @return intent Intent used to bind to an instance of the services lib.
+ */
+ Intent getAvailableServicesInstance(@NonNull final Context context) {
+ final PackageManager pm = context.getPackageManager();
+
+ //Check if an instance of the services library is up and running.
+ final Intent serviceIntent = new Intent(SERVICES_CLAZZ_NAME);
+ final List serviceInfos = pm.queryIntentServices(serviceIntent, PackageManager.GET_META_DATA);
+ if(serviceInfos != null && !serviceInfos.isEmpty()){
+ for(ResolveInfo serviceInfo : serviceInfos) {
+ final Bundle metaData = serviceInfo.serviceInfo.metaData;
+ if (metaData == null)
+ continue;
+
+ final int coreLibVersion = metaData.getInt(METADATA_KEY, INVALID_LIB_VERSION);
+ if (coreLibVersion != INVALID_LIB_VERSION && coreLibVersion >= VersionUtils.getCoreLibVersion(context)) {
+ serviceIntent.setClassName(serviceInfo.serviceInfo.packageName, serviceInfo.serviceInfo.name);
+ return serviceIntent;
+ }
+ }
+ }
+
+ //Didn't find any that's up and running. Enable the local one
+ DroidPlannerService.enableDroidPlannerService(context, true);
+ serviceIntent.setClass(context, DroidPlannerService.class);
+ return serviceIntent;
+ }
+
+}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/ControlTower.java b/ClientLib/src/main/java/com/o3dr/android/client/ControlTower.java
index 573f073732..7c7f5695e6 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/ControlTower.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/ControlTower.java
@@ -4,17 +4,16 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
-import com.o3dr.android.client.apis.ApiAvailability;
import com.o3dr.android.client.interfaces.TowerListener;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.model.IDroidPlannerServices;
+import com.o3dr.services.android.lib.model.IDroneApi;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -25,8 +24,6 @@ public class ControlTower {
private static final String TAG = ControlTower.class.getSimpleName();
- private final Intent serviceIntent = new Intent(IDroidPlannerServices.class.getName());
-
private final IBinder.DeathRecipient binderDeathRecipient = new IBinder.DeathRecipient() {
@Override
public void binderDied() {
@@ -59,15 +56,13 @@ public void onServiceDisconnected(ComponentName name) {
private final AtomicBoolean isServiceConnecting = new AtomicBoolean(false);
private final Context context;
+ private final DroneApiListener apiListener;
private TowerListener towerListener;
private IDroidPlannerServices o3drServices;
public ControlTower(Context context) {
this.context = context;
- }
-
- IDroidPlannerServices get3drServices() {
- return o3drServices;
+ this.apiListener = new DroneApiListener(this.context);
}
public boolean isTowerConnected() {
@@ -134,22 +129,9 @@ public void connect(TowerListener listener) {
towerListener = listener;
if (!isTowerConnected() && !isServiceConnecting.get()) {
- final int apiAvailableResult = ApiAvailability.getInstance().checkApiAvailability(context);
-
- switch(apiAvailableResult){
- case ApiAvailability.API_AVAILABLE:
- final ResolveInfo info = context.getPackageManager().resolveService(serviceIntent, 0);
- if (info != null) {
- serviceIntent.setClassName(info.serviceInfo.packageName, info.serviceInfo.name);
- isServiceConnecting.set(context.bindService(serviceIntent, o3drServicesConnection,
- Context.BIND_AUTO_CREATE));
- }
- break;
-
- default:
- ApiAvailability.getInstance().showErrorDialog(context, apiAvailableResult);
- break;
- }
+ final Intent serviceIntent = ApiAvailability.getInstance().getAvailableServicesInstance(context);
+ isServiceConnecting.set(context.bindService(serviceIntent, o3drServicesConnection,
+ Context.BIND_AUTO_CREATE));
}
}
@@ -166,11 +148,19 @@ public void disconnect() {
try {
context.unbindService(o3drServicesConnection);
} catch (Exception e) {
- Log.e(TAG, "Error occurred while unbinding from 3DR Services.");
+ Log.e(TAG, "Error occurred while unbinding from DroneKit-Android.");
}
}
- String getApplicationId() {
+ IDroneApi registerDroneApi() throws RemoteException {
+ return o3drServices.registerDroneApi(this.apiListener, getApplicationId());
+ }
+
+ void releaseDroneApi(IDroneApi droneApi) throws RemoteException {
+ o3drServices.releaseDroneApi(droneApi);
+ }
+
+ private String getApplicationId() {
return context.getPackageName();
}
}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/Drone.java b/ClientLib/src/main/java/com/o3dr/android/client/Drone.java
index d3f42c6866..65a526c0f8 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/Drone.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/Drone.java
@@ -9,26 +9,15 @@
import android.os.SystemClock;
import android.util.Log;
-import com.o3dr.android.client.apis.CalibrationApi;
-import com.o3dr.android.client.apis.ControlApi;
-import com.o3dr.android.client.apis.ExperimentalApi;
-import com.o3dr.android.client.apis.FollowApi;
import com.o3dr.android.client.apis.MissionApi;
import com.o3dr.android.client.apis.VehicleApi;
import com.o3dr.android.client.interfaces.DroneListener;
import com.o3dr.android.client.interfaces.LinkListener;
-import com.o3dr.android.client.utils.TxPowerComplianceCountries;
-import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.calibration.magnetometer.MagnetometerCalibrationStatus;
import com.o3dr.services.android.lib.drone.companion.solo.SoloAttributes;
-import com.o3dr.services.android.lib.drone.companion.solo.SoloEventExtras;
-import com.o3dr.services.android.lib.drone.companion.solo.SoloEvents;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
-import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
-import com.o3dr.services.android.lib.gcs.follow.FollowLocationSource;
-import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.drone.mission.Mission;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
import com.o3dr.services.android.lib.drone.property.Altitude;
@@ -43,13 +32,11 @@
import com.o3dr.services.android.lib.drone.property.Speed;
import com.o3dr.services.android.lib.drone.property.State;
import com.o3dr.services.android.lib.drone.property.Type;
-import com.o3dr.services.android.lib.drone.property.VehicleMode;
import com.o3dr.services.android.lib.gcs.follow.FollowState;
-import com.o3dr.services.android.lib.gcs.follow.FollowType;
-import com.o3dr.services.android.lib.gcs.returnToMe.ReturnToMeState;
+import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.gcs.link.LinkEvent;
import com.o3dr.services.android.lib.gcs.link.LinkEventExtra;
-import com.o3dr.services.android.lib.mavlink.MavlinkMessageWrapper;
+import com.o3dr.services.android.lib.gcs.returnToMe.ReturnToMeState;
import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.IDroneApi;
import com.o3dr.services.android.lib.model.IObserver;
@@ -108,7 +95,6 @@ public void binderDied() {
private Handler handler;
private ControlTower serviceMgr;
private DroneObserver droneObserver;
- private DroneApiListener apiListener;
private final AtomicReference droneApiRef = new AtomicReference<>(null);
private ConnectionParameter connectionParameter;
@@ -136,7 +122,6 @@ public Drone(Context context) {
void init(ControlTower controlTower, Handler handler) {
this.handler = handler;
this.serviceMgr = controlTower;
- this.apiListener = new DroneApiListener(this);
this.droneObserver = new DroneObserver(this);
}
@@ -155,7 +140,7 @@ synchronized void start() {
}
try {
- droneApi = serviceMgr.get3drServices().registerDroneApi(this.apiListener, serviceMgr.getApplicationId());
+ droneApi = serviceMgr.registerDroneApi();
droneApi.asBinder().linkToDeath(binderDeathRecipient, 0);
} catch (RemoteException e) {
throw new IllegalStateException("Unable to retrieve a valid drone handle.");
@@ -179,7 +164,7 @@ synchronized void destroy() {
try {
if (isStarted(droneApi)) {
droneApi.asBinder().unlinkToDeath(binderDeathRecipient, 0);
- serviceMgr.get3drServices().releaseDroneApi(droneApi);
+ serviceMgr.releaseDroneApi(droneApi);
}
} catch (RemoteException | NoSuchElementException e) {
Log.e(TAG, e.getMessage(), e);
@@ -614,141 +599,12 @@ private void removeAttributesObserver(IDroneApi droneApi, IObserver observer) {
}
}
- /**
- * @deprecated Use {@link VehicleApi#setVehicleMode(VehicleMode)} instead.
- */
- public void changeVehicleMode(VehicleMode newMode) {
- VehicleApi.getApi(this).setVehicleMode(newMode);
- }
-
- /**
- * @deprecated Use {@link VehicleApi#refreshParameters()} instead.
- */
- public void refreshParameters() {
- VehicleApi.getApi(this).refreshParameters();
- }
-
- /**
- * @deprecated Use {@link VehicleApi#writeParameters(Parameters)} instead.
- */
- public void writeParameters(Parameters parameters) {
- VehicleApi.getApi(this).writeParameters(parameters);
- }
-
- /**
- * @deprecated Use {@link MissionApi#setMission(Mission, boolean)} instead.
- */
- public void setMission(Mission mission, boolean pushToDrone) {
- MissionApi.getApi(this).setMission(mission, pushToDrone);
- }
-
- /**
- * @deprecated Use {@link MissionApi#generateDronie()} instead.
- */
- public void generateDronie() {
- MissionApi.getApi(this).generateDronie();
- }
-
- /**
- * @deprecated Use {@link VehicleApi#arm(boolean)} instead.
- */
- public void arm(boolean arm) {
- VehicleApi.getApi(this).arm(arm);
- }
-
- /**
- * @deprecated Use {@link CalibrationApi#startIMUCalibration()} instead.
- */
- public void startIMUCalibration() {
- CalibrationApi.getApi(this).startIMUCalibration();
- }
-
- /**
- * @deprecated Use {@link CalibrationApi#sendIMUAck(int)} instead.
- */
- public void sendIMUCalibrationAck(int step) {
- CalibrationApi.getApi(this).sendIMUAck(step);
- }
-
- /**
- * @deprecated Use {@link ControlApi#takeoff(double, AbstractCommandListener)} instead.
- */
- public void doGuidedTakeoff(double altitude) {
- ControlApi.getApi(this).takeoff(altitude, null);
- }
-
- /**
- * @deprecated Use {@link ControlApi#pauseAtCurrentLocation(AbstractCommandListener)} instead.
- */
- public void pauseAtCurrentLocation() {
- ControlApi.getApi(this).pauseAtCurrentLocation(null);
- }
-
- /**
- * @deprecated Use {@link ControlApi#goTo(LatLong, boolean, AbstractCommandListener)} instead.
- */
- public void sendGuidedPoint(LatLong point, boolean force) {
- ControlApi.getApi(this).goTo(point, force, null);
- }
-
- /**
- * @deprecated Use {@link ExperimentalApi#sendMavlinkMessage(MavlinkMessageWrapper)} instead.
- */
- public void sendMavlinkMessage(MavlinkMessageWrapper messageWrapper) {
- ExperimentalApi.getApi(this).sendMavlinkMessage(messageWrapper);
- }
-
- /**
- * @deprecated Use {@link ControlApi#climbTo(double)} instead.
- */
- public void setGuidedAltitude(double altitude) {
- ControlApi.getApi(this).climbTo(altitude);
- }
-
- /**
- * @deprecated Use {@link FollowApi#enableFollowMe(FollowType, com.o3dr.services.android.lib.gcs.follow.FollowLocationSource)} instead.
- */
- public void enableFollowMe(FollowType followType) {
- FollowApi.getApi(this).enableFollowMe(followType, FollowLocationSource.INTERNAL);
- }
-
- /**
- * @deprecated Use {@link FollowApi#disableFollowMe()} instead.
- */
- public void disableFollowMe() {
- FollowApi.getApi(this).disableFollowMe();
- }
-
- /**
- * @deprecated Use {@link ExperimentalApi#triggerCamera()} instead.
- */
- public void triggerCamera() {
- ExperimentalApi.getApi(this).triggerCamera();
- }
-
- /**
- * @deprecated Use {@link MissionApi#loadWaypoints()} instead.
- */
- public void loadWaypoints() {
- MissionApi.getApi(this).loadWaypoints();
- }
-
public Handler getHandler() {
return handler;
}
- void notifyDroneConnectionFailed(final ConnectionResult result) {
- if (droneListeners.isEmpty()) {
- return;
- }
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- for (DroneListener listener : droneListeners)
- listener.onDroneConnectionFailed(result);
- }
- });
+ public ExecutorService getAsyncScheduler(){
+ return asyncScheduler;
}
void notifyAttributeUpdated(final String attributeEvent, final Bundle extras) {
@@ -780,16 +636,6 @@ public void onRetrievalFailed() {
checkForGroundCollision();
break;
- //TODO remove this when deprecated methods are deleted in 3.0
- // This ensures that the api is backwards compatible
- case SoloEvents.SOLO_TX_POWER_COMPLIANCE_COUNTRY_UPDATED:
- String compliantCountry = extras.getString(SoloEventExtras.EXTRA_SOLO_TX_POWER_COMPLIANT_COUNTRY);
- final Bundle eventInfo = new Bundle(1);
- boolean isEUCompliant = !TxPowerComplianceCountries.getDefaultCountry().name().equals(compliantCountry);
- eventInfo.putBoolean(SoloEventExtras.EXTRA_SOLO_EU_TX_POWER_COMPLIANT, isEUCompliant);
- sendDroneEventToListeners(SoloEvents.SOLO_EU_TX_POWER_COMPLIANCE_UPDATED, eventInfo);
- break;
-
case LinkEvent.LINK_STATE_UPDATED:
sendLinkEventToListener(extras);
return;
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/DroneApiListener.java b/ClientLib/src/main/java/com/o3dr/android/client/DroneApiListener.java
index 43b3e35a71..a6881cd3b5 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/DroneApiListener.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/DroneApiListener.java
@@ -1,5 +1,6 @@
package com.o3dr.android.client;
+import android.content.Context;
import android.os.RemoteException;
import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
@@ -11,16 +12,14 @@
*/
public class DroneApiListener extends IApiListener.Stub {
- private final Drone drone;
+ private final Context context;
- public DroneApiListener(Drone drone){
- this.drone = drone;
+ public DroneApiListener(Context context){
+ this.context = context;
}
@Override
- public void onConnectionFailed(ConnectionResult connectionResult) throws RemoteException {
- drone.notifyDroneConnectionFailed(connectionResult);
- }
+ public void onConnectionFailed(ConnectionResult connectionResult) throws RemoteException {}
@Override
public int getClientVersionCode() throws RemoteException {
@@ -29,6 +28,6 @@ public int getClientVersionCode() throws RemoteException {
@Override
public int getApiVersionCode(){
- return VersionUtils.getCoreLibVersion(drone.getContext());
+ return VersionUtils.getCoreLibVersion(this.context);
}
}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/ApiAvailability.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/ApiAvailability.java
deleted file mode 100644
index f1e69971ce..0000000000
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/ApiAvailability.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.o3dr.android.client.apis;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-
-import com.o3dr.android.client.utils.InstallServiceDialog;
-import com.o3dr.services.android.lib.model.IDroidPlannerServices;
-import com.o3dr.services.android.lib.util.version.VersionUtils;
-
-/**
- * Helper class to verify that the DroneKit-Android services APK is available and up-to-date
- * Created by Fredia Huya-Kouadio on 7/7/15.
- */
-public class ApiAvailability {
-
- private static class LazyHolder {
- private static final ApiAvailability INSTANCE = new ApiAvailability();
- }
-
- private static final String TAG = ApiAvailability.class.getSimpleName();
-
- private static final String SERVICES_CLAZZ_NAME = IDroidPlannerServices.class.getName();
- private static final String METADATA_KEY = "com.o3dr.dronekit.android.core.version";
-
- public static final int API_AVAILABLE = 0;
- public static final int API_MISSING = 1;
- public static final int API_UPDATE_REQUIRED = 2;
-
- //Private to prevent instantiation
- private ApiAvailability() {
- }
-
- public static ApiAvailability getInstance() {
- return LazyHolder.INSTANCE;
- }
-
- /**
- * Verifies that DroneKit-Android services is installed and enabled on this device, and that the version
- * installed is up-to-date.
- *
- * @param context Application context. Must not be null.
- * @return status code indicating the availability of the api.
- */
- public int checkApiAvailability(@NonNull final Context context) {
- final PackageManager pm = context.getPackageManager();
-
- //Check if DroneKit-Android services is installed.
- final Intent serviceIntent = new Intent(SERVICES_CLAZZ_NAME);
- final ResolveInfo serviceInfo = pm.resolveService(serviceIntent, PackageManager.GET_META_DATA);
- if (serviceInfo == null) {
- return API_MISSING;
- }
-
- final Bundle metaData = serviceInfo.serviceInfo.metaData;
- if (metaData == null)
- return API_UPDATE_REQUIRED;
-
- final int coreLibVersion = metaData.getInt(METADATA_KEY);
- if (coreLibVersion < VersionUtils.getCoreLibVersion(context))
- return API_UPDATE_REQUIRED;
- else
- return API_AVAILABLE;
- }
-
- /**
- * Display a dialog for an error code returned from callback to {@link ApiAvailability#checkApiAvailability(Context)}
- *
- * @param context Application context
- * @param errorCode Error code returned from callback to
- * {@link ApiAvailability#checkApiAvailability(Context)}. If errorCode is API_AVAILABLE, then this does nothing.
- */
- public void showErrorDialog(Context context, int errorCode) {
- switch (errorCode) {
- case API_MISSING:
- context.startActivity(new Intent(context, InstallServiceDialog.class)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- .putExtra(InstallServiceDialog.EXTRA_REQUIREMENT, InstallServiceDialog.REQUIRE_INSTALL));
- break;
-
- case API_UPDATE_REQUIRED:
- context.startActivity(new Intent(context, InstallServiceDialog.class)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- .putExtra(InstallServiceDialog.EXTRA_REQUIREMENT, InstallServiceDialog.REQUIRE_UPDATE));
- break;
- }
- }
-
-}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/ExperimentalApi.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/ExperimentalApi.java
index 8dbbe15f3b..fa1a85ae3d 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/ExperimentalApi.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/apis/ExperimentalApi.java
@@ -360,7 +360,7 @@ private IVideoStreamCallback getCallback() {
public void run() {
handler.removeCallbacks(reconnectTask);
if (linkConn != null)
- linkConn.connect();
+ linkConn.connect(null);
}
};
@@ -374,7 +374,7 @@ public void start() {
handler.removeCallbacks(reconnectTask);
Log.d(TAG, "Connecting to video stream...");
- this.linkConn.connect();
+ this.linkConn.connect(null);
}
public void stop() {
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/GimbalApi.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/GimbalApi.java
index f8e445f36f..158a4fd8ac 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/GimbalApi.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/apis/GimbalApi.java
@@ -10,7 +10,6 @@
import com.o3dr.services.android.lib.drone.attribute.AttributeEventExtra;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
-import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
import com.o3dr.services.android.lib.drone.property.Type;
import com.o3dr.services.android.lib.model.SimpleCommandListener;
import com.o3dr.services.android.lib.model.action.Action;
@@ -18,7 +17,12 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
-import static com.o3dr.services.android.lib.drone.action.GimbalActions.*;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.ACTION_SET_GIMBAL_MOUNT_MODE;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.ACTION_SET_GIMBAL_ORIENTATION;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.GIMBAL_MOUNT_MODE;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.GIMBAL_PITCH;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.GIMBAL_ROLL;
+import static com.o3dr.services.android.lib.drone.action.GimbalActions.GIMBAL_YAW;
public final class GimbalApi extends Api implements DroneListener {
@@ -266,11 +270,6 @@ private void notifyGimbalOrientationUpdated(GimbalOrientation orientation){
}
}
- @Override
- public void onDroneConnectionFailed(ConnectionResult result) {
-
- }
-
@Override
public void onDroneEvent(String event, Bundle extras) {
switch(event){
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/MissionApi.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/MissionApi.java
index efcbcf02d7..c0deb83c29 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/MissionApi.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/apis/MissionApi.java
@@ -1,6 +1,8 @@
package com.o3dr.android.client.apis;
+import android.net.Uri;
import android.os.Bundle;
+import android.support.annotation.Nullable;
import com.o3dr.android.client.Drone;
import com.o3dr.services.android.lib.drone.mission.Mission;
@@ -11,7 +13,24 @@
import java.util.concurrent.ConcurrentHashMap;
-import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.*;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_CHANGE_MISSION_SPEED;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_GENERATE_DRONIE;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_GOTO_WAYPOINT;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_LOAD_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_LOAD_WAYPOINTS;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_SAVE_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_SET_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_START_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_FORCE_ARM;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_FORCE_MODE_CHANGE;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_LOAD_MISSION_URI;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_MISSION_ITEM_INDEX;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_MISSION_SPEED;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_PUSH_TO_DRONE;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_SAVE_MISSION_URI;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_SET_LOADED_MISSION;
/**
* Provides access to missions specific functionality.
@@ -95,6 +114,118 @@ public void loadWaypoints() {
drone.performAsyncAction(new Action(ACTION_LOAD_WAYPOINTS));
}
+ /**
+ * Loads the mission from the given source uri
+ * @param sourceUri
+ * @param loadingCallback Invoked when the loading operation completes.
+ * @since 3.0.0
+ */
+ @Nullable
+ public void loadMission(Uri sourceUri, LoadingCallback loadingCallback) {
+ loadAndSetMission(sourceUri, false, loadingCallback);
+ }
+
+ /**
+ * Loads and sets the mission retrieved from the source uri.
+ * @param sourceUri
+ * @param loadingCallback Invoked when the loading operation completes.
+ * @since 3.0.0
+ */
+ public void loadAndSetMission(Uri sourceUri, LoadingCallback loadingCallback){
+ loadAndSetMission(sourceUri, true, loadingCallback);
+ }
+
+ private void loadAndSetMission(final Uri sourceUri, final boolean setMission, final LoadingCallback loadingCallback){
+ if(sourceUri == null){
+ throw new NullPointerException("Mission source uri must be non null.");
+ }
+ if(!setMission && loadingCallback == null){
+ // No point to load the mission if no one is listening for it.
+ return;
+ }
+
+ drone.getAsyncScheduler().execute(new Runnable() {
+ @Override
+ public void run() {
+ postLoadingStart(loadingCallback);
+
+ Bundle params = new Bundle();
+ params.putParcelable(EXTRA_LOAD_MISSION_URI, sourceUri);
+ params.putBoolean(EXTRA_SET_LOADED_MISSION, setMission);
+
+ Action loadAction = new Action(ACTION_LOAD_MISSION, params);
+ boolean result = drone.performAction(loadAction);
+ if (loadingCallback != null) {
+ if (result) {
+ final Mission loadedMission = loadAction.getData().getParcelable(EXTRA_MISSION);
+ if (loadedMission == null) {
+ postLoadingFailed(loadingCallback);
+ }
+ else {
+ postLoadingComplete(loadedMission, loadingCallback);
+ }
+ } else {
+ postLoadingFailed(loadingCallback);
+ }
+ }
+ }
+ });
+ }
+
+ private void postLoadingStart(final LoadingCallback> callback) {
+ if(callback != null){
+ drone.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onLoadingStart();
+ }
+ });
+ }
+ }
+
+ private void postLoadingFailed(final LoadingCallback> callback){
+ if(callback != null){
+ drone.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onLoadingFailed();
+ }
+ });
+ }
+ }
+
+ private void postLoadingComplete(final T loaded, final LoadingCallback callback) {
+ if(callback != null){
+ drone.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onLoadingComplete(loaded);
+ }
+ });
+ }
+ }
+
+ /**
+ * Saves a mission to the given save uri.
+ * @param mission Mission to save
+ * @param saveUri Destination uri for the mission
+ * @param listener
+ *
+ * @since 3.0.0
+ */
+ public void saveMission(Mission mission, Uri saveUri, AbstractCommandListener listener){
+ if(mission == null){
+ throw new NullPointerException("Mission must be non null.");
+ }
+ if(saveUri == null){
+ throw new NullPointerException("Mission destination uri must be non null.");
+ }
+ Bundle params = new Bundle();
+ params.putParcelable(EXTRA_MISSION, mission);
+ params.putParcelable(EXTRA_SAVE_MISSION_URI, saveUri);
+ drone.performAsyncActionOnDroneThread(new Action(ACTION_SAVE_MISSION, params), listener);
+ }
+
/**
* Build and return complex mission item.
* @param itemBundle bundle containing the complex mission item to update.
@@ -153,4 +284,10 @@ public void setMissionSpeed(float speed, AbstractCommandListener listener) {
params.putFloat(EXTRA_MISSION_SPEED, speed);
drone.performAsyncActionOnDroneThread(new Action(ACTION_CHANGE_MISSION_SPEED, params), listener);
}
+
+ public interface LoadingCallback {
+ void onLoadingStart();
+ void onLoadingComplete(T loaded);
+ void onLoadingFailed();
+ }
}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/VehicleApi.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/VehicleApi.java
index 1b7ef38b43..aa3f026e77 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/VehicleApi.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/apis/VehicleApi.java
@@ -3,7 +3,6 @@
import android.os.Bundle;
import com.o3dr.android.client.Drone;
-import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.drone.property.Parameters;
@@ -55,11 +54,9 @@ public static VehicleApi getApi(final Drone drone) {
}
private final Drone drone;
- private final ControlApi controlApi;
private VehicleApi(Drone drone) {
this.drone = drone;
- this.controlApi = ControlApi.getApi(drone);
}
/**
@@ -155,76 +152,6 @@ public void writeParameters(Parameters parameters) {
drone.performAsyncAction(new Action(ACTION_WRITE_PARAMETERS, params));
}
- /*
- Deprecated apis
- */
-
- /**
- * @param altitude altitude in meters
- * @deprecated Use {@link ControlApi#takeoff(double, AbstractCommandListener)} instead.
- * Perform a guided take off.
- */
- public void takeoff(double altitude) {
- controlApi.takeoff(altitude, null);
- }
-
- /**
- * @param altitude altitude in meters
- * @param listener Register a callback to receive update of the command execution state.
- * @deprecated Use {@link ControlApi#takeoff(double, AbstractCommandListener)} instead.
- * Perform a guided take off.
- */
- public void takeoff(double altitude, AbstractCommandListener listener) {
- controlApi.takeoff(altitude, listener);
- }
-
- /**
- * @param point guided point location
- * @param force true to enable guided mode is required.
- * @deprecated Use {@link ControlApi#goTo(LatLong, boolean, AbstractCommandListener)} instead.
- * Send a guided point to the connected drone.
- */
- public void sendGuidedPoint(LatLong point, boolean force) {
- controlApi.goTo(point, force, null);
- }
-
- /**
- * @param point guided point location
- * @param force true to enable guided mode is required.
- * @param listener Register a callback to receive update of the command execution state.
- * @deprecated Use {@link ControlApi#goTo(LatLong, boolean, AbstractCommandListener)} instead.
- * Send a guided point to the connected drone.
- */
- public void sendGuidedPoint(LatLong point, boolean force, AbstractCommandListener listener) {
- controlApi.goTo(point, force, listener);
- }
-
- /**
- * @param altitude altitude in meters
- * @deprecated Use {@link ControlApi#climbTo(double)} instead.
- * Set the altitude for the guided point.
- */
- public void setGuidedAltitude(double altitude) {
- controlApi.climbTo(altitude);
- }
-
- /**
- * @deprecated Use {@link ControlApi#pauseAtCurrentLocation(AbstractCommandListener)} instead.
- * Pause the vehicle at its current location.
- */
- public void pauseAtCurrentLocation() {
- controlApi.pauseAtCurrentLocation(null);
- }
-
- /**
- * @param listener Register a callback to receive update of the command execution state.
- * @deprecated Use {@link ControlApi#pauseAtCurrentLocation(AbstractCommandListener)} instead.
- * Pause the vehicle at its current location.
- */
- public void pauseAtCurrentLocation(final AbstractCommandListener listener) {
- controlApi.pauseAtCurrentLocation(listener);
- }
-
/**
* Changes the vehicle home location.
*
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/apis/solo/SoloConfigApi.java b/ClientLib/src/main/java/com/o3dr/android/client/apis/solo/SoloConfigApi.java
index cae78919ef..2b58b0268e 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/apis/solo/SoloConfigApi.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/apis/solo/SoloConfigApi.java
@@ -91,20 +91,6 @@ public void updateControllerMode(@SoloControllerMode.ControllerMode int controll
drone.performAsyncActionOnDroneThread(new Action(ACTION_UPDATE_CONTROLLER_MODE, params), listener);
}
- /**
- * @deprecated Use {@link #updateTxPowerComplianceCountry(TxPowerComplianceCountries compliantCountry, AbstractCommandListener listener)} instead.
- */
- public void updateEUTxPowerCompliance(boolean isEUCompliant, AbstractCommandListener listener) {
- TxPowerComplianceCountries compliantCountry;
- if (isEUCompliant) {
- compliantCountry = TxPowerComplianceCountries.getDefaultEUCountry();
- } else {
- compliantCountry = TxPowerComplianceCountries.getDefaultCountry();
- }
-
- updateTxPowerComplianceCountry(compliantCountry, listener);
- }
-
/**
* Updates the tx power compliance to the specified country.
*
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/interfaces/DroneListener.java b/ClientLib/src/main/java/com/o3dr/android/client/interfaces/DroneListener.java
index 1fa92a64fb..36239c3725 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/interfaces/DroneListener.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/interfaces/DroneListener.java
@@ -2,21 +2,11 @@
import android.os.Bundle;
-import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
-import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-
/**
* Created by fhuya on 11/18/14.
*/
public interface DroneListener {
- /**
- * @deprecated Use {@link LinkListener#onLinkStateUpdated(LinkConnectionStatus)} instead.
- *
- * @param result
- */
- void onDroneConnectionFailed(ConnectionResult result);
-
void onDroneEvent(String event, Bundle extras);
void onDroneServiceInterrupted(String errorMsg);
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/FileUtils.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/FileUtils.java
similarity index 55%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/FileUtils.java
rename to ClientLib/src/main/java/com/o3dr/android/client/utils/FileUtils.java
index 3f4d73a90e..14d2d97efa 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/FileUtils.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/FileUtils.java
@@ -1,7 +1,9 @@
-package org.droidplanner.services.android.utils.file;
+package com.o3dr.android.client.utils;
import android.content.Context;
+import org.droidplanner.services.android.impl.utils.file.DirectoryPath;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -13,8 +15,7 @@
public class FileUtils {
public static final String CAMERA_FILENAME_EXT = ".xml";
-
- public static final String TLOG_FILENAME_EXT = ".tlog";
+ public static final SimpleDateFormat timestampFormatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS", Locale.US);
public static File[] getCameraInfoFileList(Context context) {
FilenameFilter filter = new FilenameFilter() {
@@ -26,28 +27,7 @@ public boolean accept(File dir, String filename) {
return getFileList(DirectoryPath.getCameraInfoPath(context), filter);
}
- public static File[] getTLogFileList(Context context, String appId) {
- final FilenameFilter tlogFilter = new FilenameFilter() {
- public boolean accept(File dir, String filename) {
- return filename.endsWith(TLOG_FILENAME_EXT);
- }
- };
-
- File[] unsentFiles = getFileList(DirectoryPath.getTLogPath(context, appId).getPath(), tlogFilter);
- File[] sentFiles = getFileList(DirectoryPath.getTLogSentPath(context, appId).getPath(), tlogFilter);
- File[] tlogFiles = new File[unsentFiles.length + sentFiles.length];
-
- int i = 0;
- for(File file : unsentFiles)
- tlogFiles[i++] = file;
-
- for(File file : sentFiles)
- tlogFiles[i++] = file;
-
- return tlogFiles;
- }
-
- static public File[] getFileList(String path, FilenameFilter filter) {
+ private static File[] getFileList(String path, FilenameFilter filter) {
File mPath = new File(path);
if(!mPath.exists())
return new File[0];
@@ -70,11 +50,35 @@ public static FileOutputStream getExceptionFileStream(Context context) throws Fi
* Timestamp for logs in the Mission Planner Format
*/
static public String getTimeStamp(long timestamp) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.US);
- return sdf.format(new Date(timestamp));
+ return timestampFormatter.format(new Date(timestamp));
}
- static public String getTimeStamp() {
+ private static String getTimeStamp() {
return getTimeStamp(System.currentTimeMillis());
}
+
+ public static String getFilenameWithoutExtension(File file){
+ return getFilenameWithoutExtension(file.getName());
+ }
+
+ public static String getFilenameWithoutExtension(String filename){
+ int pos = filename.lastIndexOf(".");
+ if (pos >= 0) {
+ filename = filename.substring(0, pos);
+ }
+ return filename;
+ }
+
+ public static String getFileExtension(File file){
+ return getFileExtension(file.getName());
+ }
+
+ public static String getFileExtension(String filename){
+ String extension = "";
+ int pos = filename.lastIndexOf(".");
+ if(pos >= 0){
+ extension = filename.substring(pos);
+ }
+ return extension;
+ }
}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/InstallServiceDialog.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/InstallServiceDialog.java
deleted file mode 100644
index 652bda078c..0000000000
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/InstallServiceDialog.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.o3dr.android.client.utils;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.o3dr.android.client.R;
-
-/**
- * Created by fhuya on 11/14/14.
- */
-public class InstallServiceDialog extends FragmentActivity {
-
- public static final String EXTRA_REQUIREMENT = "extra_requirement";
-
- public static final int REQUIRE_INSTALL = 0;
- public static final int REQUIRE_UPDATE = 1;
-
- private Button installButton;
- private TextView dialogTitle;
- private TextView dialogMsg;
-
- @Override
- public void onCreate(Bundle savedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_install_service_dialog);
-
- final Button cancelButton = (Button) findViewById(R.id.dialog_cancel_button);
- cancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
-
- dialogTitle = (TextView) findViewById(R.id.dialog_title);
- dialogMsg = (TextView) findViewById(R.id.dialog_message);
-
- installButton = (Button) findViewById(R.id.dialog_install_button);
- installButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final PackageManager pm = getPackageManager();
-
- Intent marketIntent = new Intent(Intent.ACTION_VIEW,
- Uri.parse("market://details?id=org.droidplanner.services.android"));
- if(pm.resolveActivity(marketIntent, 0) == null){
- marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=org.droidplanner.services.android"));
- if(pm.resolveActivity(marketIntent, 0) == null){
- marketIntent = null;
- }
- }
-
- if(marketIntent != null)
- startActivity(marketIntent);
- else{
- Toast.makeText(getApplicationContext(), "No app found to complete the process.", Toast
- .LENGTH_LONG).show();
- }
-
- finish();
- }
- });
-
- handleIntent(getIntent());
- }
-
- @Override
- public void onNewIntent(Intent intent){
- super.onNewIntent(intent);
- handleIntent(intent);
- }
-
- private void handleIntent(Intent intent){
- if(intent == null){
- finish();
- return;
- }
-
- final int requirement = intent.getIntExtra(EXTRA_REQUIREMENT, REQUIRE_INSTALL);
- switch(requirement){
- case REQUIRE_INSTALL:
- installButton.setText(R.string.install_service_dialog_install_button);
- dialogTitle.setText(R.string.install_service_dialog_title);
- dialogMsg.setText(R.string.install_service_dialog_message);
- break;
-
- case REQUIRE_UPDATE:
- installButton.setText(R.string.update_service_dialog_update_button);
- dialogTitle.setText(R.string.update_service_dialog_title);
- dialogMsg.setText(R.string.update_service_dialog_message);
- break;
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/LogToFileTree.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/LogToFileTree.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/utils/LogToFileTree.java
rename to ClientLib/src/main/java/com/o3dr/android/client/utils/LogToFileTree.java
index 9e30bae12c..70a0090e0c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/LogToFileTree.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/LogToFileTree.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.utils;
+package com.o3dr.android.client.utils;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
-import org.droidplanner.services.android.BuildConfig;
+import com.o3dr.android.client.BuildConfig;
import java.io.File;
import java.io.FileOutputStream;
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/AbstractIpConnection.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/AbstractIpConnection.java
index fbc3c98631..786a1f684f 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/AbstractIpConnection.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/AbstractIpConnection.java
@@ -1,5 +1,6 @@
package com.o3dr.android.client.utils.connection;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.os.RemoteException;
@@ -12,6 +13,7 @@
import java.nio.ByteBuffer;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Base class for ip connection (tcp, udp).
@@ -43,6 +45,7 @@ public abstract class AbstractIpConnection {
private final LinkedBlockingQueue packetsToSend = new LinkedBlockingQueue<>();
private final AtomicInteger connectionStatus = new AtomicInteger(STATE_DISCONNECTED);
+ private final AtomicReference extrasHolder = new AtomicReference<>();
private final boolean isSendingDisabled;
private final boolean isReadingDisabled;
@@ -58,7 +61,7 @@ public void run() {
try {
try {
- open();
+ open(extrasHolder.get());
connectionStatus.set(STATE_CONNECTED);
if(ipConnectionListener != null)
ipConnectionListener.onIpConnected();
@@ -200,7 +203,7 @@ public AbstractIpConnection(Handler handler, int readBufferSize, boolean disable
this.isPolling = isPolling;
}
- protected abstract void open() throws IOException;
+ protected abstract void open(Bundle extras) throws IOException;
protected abstract int read(ByteBuffer buffer) throws IOException;
@@ -210,16 +213,22 @@ public AbstractIpConnection(Handler handler, int readBufferSize, boolean disable
/**
* Establish an ip connection. If successful, ConnectionListener#onIpConnected() is called.
+ * @param extras
*/
- public void connect(){
+ public void connect(Bundle extras){
if(connectionStatus.compareAndSet(STATE_DISCONNECTED, STATE_CONNECTING)){
Log.i(TAG, "Starting manager thread.");
+ extrasHolder.set(extras);
managerThread = new Thread(managerTask, "IP Connection-Manager Thread");
managerThread.setPriority(Thread.MAX_PRIORITY);
managerThread.start();
}
}
+ public Bundle getConnectionExtras(){
+ return extrasHolder.get();
+ }
+
/**
* Disconnect an existing ip connection. If successful, ConnectionListener#onIpDisconnected() is called.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/TcpConnection.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/TcpConnection.java
index 2a133ec257..9120a76a8e 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/TcpConnection.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/TcpConnection.java
@@ -1,7 +1,10 @@
package com.o3dr.android.client.utils.connection;
+import android.os.Bundle;
import android.os.Handler;
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
@@ -29,10 +32,11 @@ public TcpConnection(Handler handler, String serverIp, int serverPort){
}
@Override
- protected void open() throws IOException {
+ protected void open(Bundle extras) throws IOException {
final InetAddress serverAddr = InetAddress.getByName(serverIp);
socket = new Socket();
socket.setReuseAddress(true);
+ NetworkUtils.bindSocketToNetwork(extras, socket);
socket.connect(new InetSocketAddress(serverAddr, serverPort), CONNECTION_TIMEOUT);
connOut = new BufferedOutputStream(socket.getOutputStream());
connIn = new BufferedInputStream(socket.getInputStream());
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/UdpConnection.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/UdpConnection.java
index 2315745e21..6188883035 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/UdpConnection.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/connection/UdpConnection.java
@@ -1,8 +1,11 @@
package com.o3dr.android.client.utils.connection;
+import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
+
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
@@ -51,13 +54,14 @@ public UdpConnection(Handler handler, String address, int hostPort, int serverPo
}
@Override
- protected void open() throws IOException {
+ protected void open(Bundle extras) throws IOException {
Log.d(TAG, "Opening udp connection.");
socket = (serverPort == -1) ?new DatagramSocket() : new DatagramSocket(serverPort);
socket.setBroadcast(true);
socket.setReuseAddress(true);
socket.setSoTimeout(readTimeout);
+ NetworkUtils.bindSocketToNetwork(extras, socket);
}
@Override
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogParser.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogParser.java
index 748e3a8ed8..8be0cb4efa 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogParser.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogParser.java
@@ -1,5 +1,6 @@
package com.o3dr.android.client.utils.data.tlog;
+import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.util.Log;
@@ -7,14 +8,15 @@
import com.MAVLink.MAVLinkPacket;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.Parser;
+import com.o3dr.services.android.lib.util.UriUtils;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
@@ -36,7 +38,8 @@ private TLogParser(){}
* Iterator class to iterate and parse the Tlog file.
*/
public static class TLogIterator {
- private File file;
+ private final Context context;
+ private final Uri uri;
private DataInputStream in = null;
private final Handler handler;
@@ -52,8 +55,8 @@ public boolean acceptEvent(Event event) {
*
* @param uri Location of the TLog files
*/
- public TLogIterator(Uri uri) {
- this(uri, new Handler());
+ public TLogIterator(Context context, Uri uri) {
+ this(context, uri, new Handler());
}
/**
@@ -62,9 +65,10 @@ public TLogIterator(Uri uri) {
* @param uri Location of the TLog files
* @param handler Handler to post results to
*/
- public TLogIterator(Uri uri, Handler handler) {
+ public TLogIterator(Context context, Uri uri, Handler handler) {
+ this.context = context;
this.handler = handler;
- file = new File(uri.toString());
+ this.uri = uri;
}
/**
@@ -72,8 +76,8 @@ public TLogIterator(Uri uri, Handler handler) {
*
* @throws FileNotFoundException
*/
- public void start() throws FileNotFoundException {
- in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+ public void start() throws IOException {
+ in = new DataInputStream(new BufferedInputStream(UriUtils.getInputStream(context, this.uri)));
}
/**
@@ -107,16 +111,12 @@ public void nextAsync(final TLogIteratorFilter filter, final TLogIteratorCallbac
@Override
public void run() {
try {
- Event event = next(in);
- while (event != null) {
- if (filter.acceptEvent(event)) {
- sendResult(callback, event);
- return;
- }
- event = next(in);
+ Event event = blockingNext(filter);
+ if (event != null) {
+ sendResult(callback, event);
+ } else {
+ sendFailed(callback, new NoSuchElementException());
}
-
- sendFailed(callback, new NoSuchElementException());
} catch (IOException e) {
sendFailed(callback, e);
}
@@ -124,6 +124,35 @@ public void run() {
});
}
+ /**
+ * Retrieves next tlog data event.
+ * Note: This method blocks and should not be used on the main thread.
+ * @return
+ * @throws IOException
+ */
+ public Event blockingNext() throws IOException {
+ return blockingNext(DEFAULT_FILTER);
+ }
+
+ /**
+ * Retrieves next tlog data event matching the given filter parameter.
+ * Note: This method blocks and should not be used on the main thread.
+ * @param filter
+ * @return
+ * @throws IOException
+ */
+ public Event blockingNext(final TLogIteratorFilter filter) throws IOException {
+ Event event = next(in);
+ while (event != null) {
+ if (filter.acceptEvent(event)) {
+ return event;
+ }
+ event = next(in);
+ }
+
+ return null;
+ }
+
private void sendResult(final TLogIteratorCallback callback, final Event event) {
if (callback != null) {
handler.post(new Runnable() {
@@ -165,8 +194,8 @@ public boolean shouldIterate() {
* @return
* @throws Exception
*/
- public static List getAllEvents(final Uri uri) throws Exception {
- return getAllEvents(uri, DEFAULT_FILTER);
+ public static List getAllEvents(Context context, final Uri uri) throws Exception {
+ return getAllEvents(context, uri, DEFAULT_FILTER);
}
/**
@@ -176,11 +205,11 @@ public static List getAllEvents(final Uri uri) throws Exceptio
* @return
* @throws Exception
*/
- public static List getAllEvents(final Uri uri, final TLogParserFilter filter) throws Exception {
- File file = new File(uri.getPath());
+ public static List getAllEvents(Context context, final Uri uri, final TLogParserFilter filter) throws Exception {
+ InputStream inputStream = UriUtils.getInputStream(context, uri);
DataInputStream in = null;
try {
- in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+ in = new DataInputStream(new BufferedInputStream(inputStream));
ArrayList eventList = new ArrayList<>();
Event event = next(in);
while (event != null && filter.shouldIterate()) {
@@ -210,8 +239,8 @@ public static List getAllEvents(final Uri uri, final TLogParse
* @param uri {@link Uri}
* @param callback {@link TLogParserCallback}
*/
- public static void getAllEventsAsync(final Handler handler, final Uri uri, final TLogParserCallback callback) {
- getAllEventsAsync(handler, uri, DEFAULT_FILTER, callback);
+ public static void getAllEventsAsync(Context context, final Handler handler, final Uri uri, final TLogParserCallback callback) {
+ getAllEventsAsync(context, handler, uri, DEFAULT_FILTER, callback);
}
/**
@@ -222,12 +251,12 @@ public static void getAllEventsAsync(final Handler handler, final Uri uri, final
* @param filter {@link TLogParserFilter}
* @param callback {@link TLogParserCallback}
*/
- public static void getAllEventsAsync(final Handler handler, final Uri uri, final TLogParserFilter filter, final TLogParserCallback callback) {
+ public static void getAllEventsAsync(final Context context, final Handler handler, final Uri uri, final TLogParserFilter filter, final TLogParserCallback callback) {
getInstance().execute(new Runnable() {
@Override
public void run() {
try {
- List eventList = getAllEvents(uri, filter);
+ List eventList = getAllEvents(context, uri, filter);
if (eventList.isEmpty()) {
sendFailed(handler, callback, new NoSuchElementException());
@@ -290,7 +319,9 @@ private static class InitializeExecutorService {
/**
* Mavlink message event.
*/
- public static class Event {
+ public static class Event implements Serializable {
+ private static final long serialVersionUID = -3035618718582382608L;
+
private long timestamp;
private MAVLinkMessage mavLinkMessage;
@@ -316,5 +347,30 @@ public long getTimestamp() {
public MAVLinkMessage getMavLinkMessage() {
return mavLinkMessage;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Event)) {
+ return false;
+ }
+
+ Event event = (Event) o;
+
+ if (timestamp != event.timestamp) {
+ return false;
+ }
+ return mavLinkMessage != null ? mavLinkMessage.equals(event.mavLinkMessage) : event.mavLinkMessage == null;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (timestamp ^ (timestamp >>> 32));
+ result = 31 * result + (mavLinkMessage != null ? mavLinkMessage.hashCode() : 0);
+ return result;
+ }
}
}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogPicker.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogPicker.java
deleted file mode 100644
index 98cdd32c74..0000000000
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/data/tlog/TLogPicker.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.o3dr.android.client.utils.data.tlog;
-
-import android.app.Activity;
-import android.content.Intent;
-
-import com.o3dr.services.android.lib.data.ServiceDataContract;
-
-/**
- * Provides utility to select a tlog files.
- */
-public class TLogPicker {
-
- public static void startTLogPicker(Activity activity, int resultCode){
- if(activity == null)
- return;
-
- final Intent requestIntent = new Intent(ServiceDataContract.ACTION_REQUEST_TLOG)
- .putExtra(ServiceDataContract.EXTRA_REQUEST_TLOG_APP_ID, activity.getPackageName())
- .setType(ServiceDataContract.TLOG_MIME_TYPE);
- activity.startActivityForResult(requestIntent, resultCode);
- }
-
- //Private constructor to prevent instantiation
- private TLogPicker(){}
-}
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/FilterByTimestampGeoTagAlgorithm.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/FilterByTimestampGeoTagAlgorithm.java
index 3327c70fbe..39df59a9dd 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/FilterByTimestampGeoTagAlgorithm.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/FilterByTimestampGeoTagAlgorithm.java
@@ -11,11 +11,8 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.SortedMap;
import java.util.TreeMap;
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagAsyncTask.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagAsyncTask.java
index 933b5dfb47..6bc0dea834 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagAsyncTask.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagAsyncTask.java
@@ -32,7 +32,7 @@ public void onProgress(int numProcessed, int numTotal) {
* Warning: this copies data to external storage
*
* @param rootDir {@link File}
- * @param events {@link List} list of events to geotag photos.
+ * @param events {@link List< com.o3dr.android.client.utils.data.tlog.TLogParser.Event>} list of events to geotag photos.
* @param photos {@link List} list of files of photos to geotag.
*/
public GeoTagAsyncTask(File rootDir, List events, ArrayList photos) {
diff --git a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagUtils.java b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagUtils.java
index e7bda97237..527f5c135c 100644
--- a/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagUtils.java
+++ b/ClientLib/src/main/java/com/o3dr/android/client/utils/geotag/GeoTagUtils.java
@@ -11,13 +11,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
/**
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/data/ServiceDataContract.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/data/ServiceDataContract.java
deleted file mode 100644
index e68f937aaa..0000000000
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/data/ServiceDataContract.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.o3dr.services.android.lib.data;
-
-import com.o3dr.services.android.lib.util.Utils;
-
-/**
- * The contract between the 3DR Services data provider, and applications. Contains definitions for the supported URIs
- * and columns.
- */
-public class ServiceDataContract {
-
- private static final String PACKAGE_NAME = Utils.PACKAGE_NAME + ".provider";
-
- /**
- * Authority for the service data provider.
- */
- public static final String DATA_PROVIDER_AUTHORITY = PACKAGE_NAME + ".dataprovider";
-
- /**
- * Authority for the file provider.
- */
- public static final String FILE_PROVIDER_AUTHORITY = PACKAGE_NAME + ".fileprovider";
-
- /**
- * Action used to request a tlog file.
- */
- public static final String ACTION_REQUEST_TLOG = PACKAGE_NAME + ".action.REQUEST_TLOG_FILE";
-
- /**
- * Key used to access the id of the app requesting the tlog data.
- */
- public static final String EXTRA_REQUEST_TLOG_APP_ID = PACKAGE_NAME + ".extra.REQUEST_TLOG_APP_ID";
-
- /**
- * Key used to access the file path for the request tlog data.
- */
- public static final String EXTRA_TLOG_ABSOLUTE_PATH = "extra_tlog_absolute_path";
-
- /**
- * Action used to notify of the availability of a tlog file.
- */
- public static final String ACTION_RETURN_TLOG = PACKAGE_NAME + ".action.RETURN_TLOG_FILE";
-
- /**
- * Mime type for a tlog file.
- */
- public static final String TLOG_MIME_TYPE = "application/octet-stream";
-}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/action/GuidedActions.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/action/GuidedActions.java
index 3bf4b42530..9273f4febb 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/action/GuidedActions.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/action/GuidedActions.java
@@ -1,7 +1,5 @@
package com.o3dr.services.android.lib.drone.action;
-import com.o3dr.services.android.lib.util.Utils;
-
/**
* Created by Fredia Huya-Kouadio on 1/19/15.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEventExtras.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEventExtras.java
index f5480e339d..bc758baa1b 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEventExtras.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEventExtras.java
@@ -20,11 +20,6 @@ private SoloEventExtras(){}
*/
public static final String EXTRA_SOLO_MESSAGE_DATA = PACKAGE_NAME + ".EXTRA_SOLO_MESSAGE_DATA";
- /**
- * @deprecated Use {@link #EXTRA_SOLO_TX_POWER_COMPLIANT_COUNTRY} instead.
- */
- public static final String EXTRA_SOLO_EU_TX_POWER_COMPLIANT = PACKAGE_NAME + ".EXTRA_SOLO_EU_TX_POWER_COMPLIANT";
-
/**
* Used to retrieve the String value specifying which country the controller is compliant with tx power levels.
* @see {@link SoloEvents#SOLO_TX_POWER_COMPLIANCE_COUNTRY_UPDATED}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEvents.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEvents.java
index c7429e459e..32f5d92b6c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEvents.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloEvents.java
@@ -50,11 +50,6 @@ private SoloEvents() {
*/
public static final String SOLO_MESSAGE_RECEIVED = PACKAGE_NAME + ".SOLO_MESSAGE_RECEIVED";
- /**
- * @deprecated Use {@link #SOLO_TX_POWER_COMPLIANCE_COUNTRY_UPDATED} instead.
- */
- public static final String SOLO_EU_TX_POWER_COMPLIANCE_UPDATED = PACKAGE_NAME + ".SOLO_EU_TX_POWER_COMPLIANCE_UPDATED";
-
/**
* Triggers upon updates to the tx power compliance.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloState.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloState.java
index 1925e137e3..94ff23e49c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloState.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/SoloState.java
@@ -88,10 +88,7 @@ public String getWifiSsid() {
return wifiSsid;
}
- /**
- * @deprecated Use {@link #getTxPowerCompliantCountry()} instead.
- */
- public boolean isEUTxPowerCompliant() {
+ private boolean isEUTxPowerCompliant() {
return !TxPowerComplianceCountries.getDefaultCountry().name().equals(txPowerCompliantCountry);
}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloActions.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloActions.java
index c6b436665e..539495fc2c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloActions.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloActions.java
@@ -1,7 +1,5 @@
package com.o3dr.services.android.lib.drone.companion.solo.action;
-import com.o3dr.services.android.lib.util.Utils;
-
/**
* Created by Fredia Huya-Kouadio on 7/10/15.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloConfigActions.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloConfigActions.java
index 098202d159..56b9bcc098 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloConfigActions.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/action/SoloConfigActions.java
@@ -33,15 +33,6 @@ private SoloConfigActions() {
*/
public static final String EXTRA_CONTROLLER_MODE = "extra_controller_mode";
- /**
- * @deprecated Use {@link #ACTION_UPDATE_TX_POWER_COMPLIANCE_COUNTRY} instead.
- */
- public static final String ACTION_UPDATE_EU_TX_POWER_COMPLIANCE = PACKAGE_NAME + ".UPDATE_EU_TX_POWER_COMPLIANCE";
- /**
- * @deprecated Use {@link #EXTRA_TX_POWER_COMPLIANT_COUNTRY_CODE} instead.
- */
- public static final String EXTRA_EU_TX_POWER_COMPLIANT = "extra_eu_tx_power_compliant";
-
public static final String ACTION_UPDATE_TX_POWER_COMPLIANCE_COUNTRY = PACKAGE_NAME + ".UPDATE_TX_POWER_COMPLIANCE_COUNTRY";
/**
* String value. The country the controller should be made compliant with.
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproConstants.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproConstants.java
index 28f28c8271..a4e440356c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproConstants.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproConstants.java
@@ -2,8 +2,6 @@
import android.support.annotation.IntDef;
-import com.MAVLink.enums.GOPRO_CAPTURE_MODE;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproState.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproState.java
index 2a01affcbb..aaa277ed4c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproState.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloGoproState.java
@@ -1,12 +1,9 @@
package com.o3dr.services.android.lib.drone.companion.solo.tlv;
import android.os.Parcel;
-import android.support.annotation.IntDef;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
/**
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/mpcc/SoloSplineAttach.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/mpcc/SoloSplineAttach.java
index 47e764c2ef..50ab52ec45 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/mpcc/SoloSplineAttach.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/mpcc/SoloSplineAttach.java
@@ -21,7 +21,7 @@
* indicate that it has reached the Path and is prepared to receive SOLO_SPLINE_SEEK messages.
*
*
- * This message is only valid once after a Path is loaded. There is no corresponding “detach”
+ * This message is only valid once after a Path is loaded. There is no corresponding "detach"
* message -- the vehicle stays attached until playback mode is exited.
*
* @since 2.8.0
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionParameter.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionParameter.java
index 68b62f0e06..2685f519d6 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionParameter.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionParameter.java
@@ -1,5 +1,6 @@
package com.o3dr.services.android.lib.drone.connection;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -11,64 +12,103 @@
*/
public class ConnectionParameter implements Parcelable {
- private final int connectionType;
+ private static final long DEFAULT_EVENTS_DISPATCHING_PERIOD = 0L; //milliseconds - disabled by default.
+
+ private final @ConnectionType.Type int connectionType;
private final Bundle paramsBundle;
- private final DroneSharePrefs droneSharePrefs;
+ private final Uri tlogLoggingUri;
+ private final long eventsDispatchingPeriod;
/**
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
* @return Returns a new {@link ConnectionParameter} with type {@link ConnectionType#TYPE_USB}
* and baud rate {@link ConnectionType#DEFAULT_USB_BAUD_RATE}.
*/
- public static ConnectionParameter newUsbConnection() {
- return newUsbConnection(ConnectionType.DEFAULT_USB_BAUD_RATE);
+ public static ConnectionParameter newUsbConnection(@Nullable Uri tlogLoggingUri) {
+ return newUsbConnection(ConnectionType.DEFAULT_USB_BAUD_RATE, tlogLoggingUri);
}
/**
*
* @param usbBaudRate Baud rate for USB connection.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @return Returns a new {@link ConnectionParameter} with type {@link ConnectionType#TYPE_USB}.
+ */
+ public static ConnectionParameter newUsbConnection(int usbBaudRate, @Nullable Uri tlogLoggingUri) {
+ return newUsbConnection(usbBaudRate, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param usbBaudRate Baud rate for USB connection.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns a new {@link ConnectionParameter} with type {@link ConnectionType#TYPE_USB}.
*/
- public static ConnectionParameter newUsbConnection(int usbBaudRate) {
+ public static ConnectionParameter newUsbConnection(int usbBaudRate, @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod){
Bundle paramsBundle = new Bundle(1);
paramsBundle.putInt(ConnectionType.EXTRA_USB_BAUD_RATE, usbBaudRate);
- return new ConnectionParameter(ConnectionType.TYPE_USB, paramsBundle);
+ return new ConnectionParameter(ConnectionType.TYPE_USB, paramsBundle, tlogLoggingUri, eventsDispatchingPeriod);
}
/**
- *
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}, using
* {@link ConnectionType#DEFAULT_UDP_SERVER_PORT} port.
*/
- public static ConnectionParameter newUdpConnection() {
- return newUdpConnection(ConnectionType.DEFAULT_UDP_SERVER_PORT);
+ public static ConnectionParameter newUdpConnection(@Nullable Uri tlogLoggingUri) {
+ return newUdpConnection(ConnectionType.DEFAULT_UDP_SERVER_PORT, tlogLoggingUri);
}
/**
*
* @param udpPort Port for the UDP connection.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}.
+ */
+ public static ConnectionParameter newUdpConnection(int udpPort, @Nullable Uri tlogLoggingUri) {
+ return newUdpConnection(udpPort, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param udpPort Port for the UDP connection.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}.
*/
- public static ConnectionParameter newUdpConnection(int udpPort) {
- return newUdpConnection(udpPort, null, 0, null);
+ public static ConnectionParameter newUdpConnection(int udpPort, @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod) {
+ Bundle paramsBundle = new Bundle();
+ paramsBundle.putInt(ConnectionType.EXTRA_UDP_SERVER_PORT, udpPort);
+
+ return new ConnectionParameter(ConnectionType.TYPE_UDP, paramsBundle, tlogLoggingUri,
+ eventsDispatchingPeriod);
}
/**
*
* @param udpPort Port for the UDP connection.
- * @param udpPingReceiverIp IP address of the UDP server to ping. If this value is null, it is ignored
- * along with udpPingReceiverPort and udpPingPayload.
+ * @param udpPingReceiverIp IP address of the UDP server to ping.
* @param udpPingReceiverPort Port of the UDP server to ping.
* @param udpPingPayload Ping payload.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
*
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}. The ping
* period is set to {@link ConnectionType#DEFAULT_UDP_PING_PERIOD}
*/
- public static ConnectionParameter newUdpConnection(int udpPort, @Nullable String udpPingReceiverIp, int udpPingReceiverPort,
- byte[] udpPingPayload) {
- return newUdpConnection(udpPort, udpPingReceiverIp, udpPingReceiverPort, udpPingPayload, ConnectionType.DEFAULT_UDP_PING_PERIOD);
+ public static ConnectionParameter newUdpWithPingConnection(int udpPort, String udpPingReceiverIp,
+ int udpPingReceiverPort,
+ byte[] udpPingPayload,
+ @Nullable Uri tlogLoggingUri) {
+ return newUdpWithPingConnection(udpPort, udpPingReceiverIp, udpPingReceiverPort,
+ udpPingPayload, ConnectionType.DEFAULT_UDP_PING_PERIOD, tlogLoggingUri);
}
/**
@@ -79,11 +119,41 @@ public static ConnectionParameter newUdpConnection(int udpPort, @Nullable String
* @param udpPingReceiverPort Port of the UDP server to ping.
* @param udpPingPayload Ping payload.
* @param pingPeriod How often should the udp ping be performed.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ *
+ * @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}.
+ */
+ public static ConnectionParameter newUdpWithPingConnection(int udpPort,
+ String udpPingReceiverIp,
+ int udpPingReceiverPort,
+ byte[] udpPingPayload,
+ long pingPeriod,
+ @Nullable Uri tlogLoggingUri) {
+ return newUdpWithPingConnection(udpPort, udpPingReceiverIp, udpPingReceiverPort,
+ udpPingPayload, pingPeriod, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param udpPort Port for the UDP connection.
+ * @param udpPingReceiverIp IP address of the UDP server to ping. If this value is null, it is ignored
+ * along with udpPingReceiverPort, udpPingPayload, and pingPeriod.
+ * @param udpPingReceiverPort Port of the UDP server to ping.
+ * @param udpPingPayload Ping payload.
+ * @param pingPeriod How often should the udp ping be performed.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_UDP}.
*/
- public static ConnectionParameter newUdpConnection(int udpPort, @Nullable String udpPingReceiverIp, int udpPingReceiverPort,
- byte[] udpPingPayload, long pingPeriod) {
+ public static ConnectionParameter newUdpWithPingConnection(int udpPort,
+ String udpPingReceiverIp,
+ int udpPingReceiverPort,
+ byte[] udpPingPayload,
+ long pingPeriod,
+ @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod) {
Bundle paramsBundle = new Bundle();
paramsBundle.putInt(ConnectionType.EXTRA_UDP_SERVER_PORT, udpPort);
@@ -94,46 +164,81 @@ public static ConnectionParameter newUdpConnection(int udpPort, @Nullable String
paramsBundle.putLong(ConnectionType.EXTRA_UDP_PING_PERIOD, pingPeriod);
}
- return new ConnectionParameter(ConnectionType.TYPE_UDP, paramsBundle);
+ return new ConnectionParameter(ConnectionType.TYPE_UDP, paramsBundle, tlogLoggingUri, eventsDispatchingPeriod);
}
/**
*
* @param tcpServerIp TCP server IP address.
- *
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_TCP}, using
* {@link ConnectionType#DEFAULT_TCP_SERVER_PORT}.
*/
- public static ConnectionParameter newTcpConnection(String tcpServerIp) {
- return newTcpConnection(tcpServerIp, ConnectionType.DEFAULT_TCP_SERVER_PORT);
+ public static ConnectionParameter newTcpConnection(String tcpServerIp, @Nullable Uri tlogLoggingUri) {
+ return newTcpConnection(tcpServerIp, ConnectionType.DEFAULT_TCP_SERVER_PORT, tlogLoggingUri);
}
/**
*
* @param tcpServerIp TCP server IP address.
* @param tcpServerPort TCP server port.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_TCP}.
+ */
+ public static ConnectionParameter newTcpConnection(String tcpServerIp, int tcpServerPort,
+ @Nullable Uri tlogLoggingUri) {
+ return newTcpConnection(tcpServerIp, tcpServerPort, tlogLoggingUri,
+ DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param tcpServerIp TCP server IP address.
+ * @param tcpServerPort TCP server port.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_TCP}.
*/
- public static ConnectionParameter newTcpConnection(String tcpServerIp, int tcpServerPort) {
+ public static ConnectionParameter newTcpConnection(String tcpServerIp, int tcpServerPort,
+ @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod) {
Bundle paramsBundle = new Bundle(2);
paramsBundle.putString(ConnectionType.EXTRA_TCP_SERVER_IP, tcpServerIp);
paramsBundle.putInt(ConnectionType.EXTRA_TCP_SERVER_PORT, tcpServerPort);
- return new ConnectionParameter(ConnectionType.TYPE_TCP, paramsBundle);
+ return new ConnectionParameter(ConnectionType.TYPE_TCP, paramsBundle, tlogLoggingUri,
+ eventsDispatchingPeriod);
}
/**
*
* @param bluetoothAddress Bluetooth address.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_BLUETOOTH}.
+ */
+ public static ConnectionParameter newBluetoothConnection(String bluetoothAddress, @Nullable Uri tlogLoggingUri){
+ return newBluetoothConnection(bluetoothAddress, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param bluetoothAddress Bluetooth address.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_BLUETOOTH}.
*/
- public static ConnectionParameter newBluetoothConnection(String bluetoothAddress) {
+ public static ConnectionParameter newBluetoothConnection(String bluetoothAddress,
+ @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod){
Bundle paramsBundle = new Bundle(1);
paramsBundle.putString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS, bluetoothAddress);
- return new ConnectionParameter(ConnectionType.TYPE_BLUETOOTH, paramsBundle);
+ return new ConnectionParameter(ConnectionType.TYPE_BLUETOOTH, paramsBundle, tlogLoggingUri,
+ eventsDispatchingPeriod);
}
/**
@@ -141,40 +246,64 @@ public static ConnectionParameter newBluetoothConnection(String bluetoothAddress
* @param ssid Wifi SSID of the solo vehicle link. This will remove a leading and/or trailing quotation.
* @param password Password to access the solo wifi network. This value can be null as long as the wifi
* configuration has been set up and stored in the mobile device's system.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged.
+ * @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_SOLO}.
+ */
+ public static ConnectionParameter newSoloConnection(String ssid, @Nullable String password, @Nullable Uri tlogLoggingUri){
+ return newSoloConnection(ssid, password, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ /**
*
+ * @param ssid Wifi SSID of the solo vehicle link. This will remove a leading and/or trailing quotation.
+ * @param password Password to access the solo wifi network. This value can be null as long as the wifi
+ * configuration has been set up and stored in the mobile device's system.
+ * @param tlogLoggingUri Uri where the tlog data should be logged. Pass null if the tlog data shouldn't be logged.
+ * @param eventsDispatchingPeriod Dictates how long (in milliseconds) to wait before dispatching
+ * buffered drone events. A value of OL means events should be
+ * dispatched as soon as they are received.
* @return Returns {@link ConnectionParameter} with type {@link ConnectionType#TYPE_SOLO}.
*/
- public static ConnectionParameter newSoloConnection(String ssid, @Nullable String password) {
+ public static ConnectionParameter newSoloConnection(String ssid, @Nullable String password,
+ @Nullable Uri tlogLoggingUri,
+ long eventsDispatchingPeriod){
String ssidWithoutQuotes = ssid.replaceAll("^\"|\"$", "");
Bundle paramsBundle = new Bundle(2);
paramsBundle.putString(ConnectionType.EXTRA_SOLO_LINK_ID, ssidWithoutQuotes);
paramsBundle.putString(ConnectionType.EXTRA_SOLO_LINK_PASSWORD, password);
- return new ConnectionParameter(ConnectionType.TYPE_SOLO, paramsBundle);
+ return new ConnectionParameter(ConnectionType.TYPE_SOLO, paramsBundle, tlogLoggingUri,
+ eventsDispatchingPeriod);
+ }
+
+ private ConnectionParameter(@ConnectionType.Type int connectionType, Bundle paramsBundle){
+ this(connectionType, paramsBundle, null);
}
/**
- * @deprecated Use one of specified static methods
*/
- //TODO: make this private version 3.0
- public ConnectionParameter(int connectionType, Bundle paramsBundle){
+ private ConnectionParameter(@ConnectionType.Type int connectionType, Bundle paramsBundle, Uri tlogLoggingUri){
+ this(connectionType, paramsBundle, tlogLoggingUri, DEFAULT_EVENTS_DISPATCHING_PERIOD);
+ }
+
+ private ConnectionParameter(@ConnectionType.Type int connectionType, Bundle paramsBundle,
+ Uri tlogLoggingUri, long eventsDispatchingPeriod){
this.connectionType = connectionType;
this.paramsBundle = paramsBundle;
- this.droneSharePrefs = null;
+ this.tlogLoggingUri = tlogLoggingUri;
+ this.eventsDispatchingPeriod = eventsDispatchingPeriod;
}
/**
- * @deprecated Use {@link ConnectionParameter#ConnectionParameter(int, Bundle)} instead.
- * @since 2.8.0
+ * Dictates how long (in milliseconds) to wait before dispatching buffered drone events.
+ * A value of OL means events should be dispatched as soon as they are received.
*/
- public ConnectionParameter(int connectionType, Bundle paramsBundle, DroneSharePrefs droneSharePrefs){
- this.connectionType = connectionType;
- this.paramsBundle = paramsBundle;
- this.droneSharePrefs = droneSharePrefs;
+ public long getEventsDispatchingPeriod() {
+ return eventsDispatchingPeriod;
}
- public int getConnectionType() {
+ public @ConnectionType.Type int getConnectionType() {
return connectionType;
}
@@ -182,8 +311,12 @@ public Bundle getParamsBundle() {
return paramsBundle;
}
- public DroneSharePrefs getDroneSharePrefs() {
- return droneSharePrefs;
+ /**
+ * Return the uri where the tlog data should be logged.
+ * @return Uri where to log the tlog data, or null if it shouldn't be logged.
+ */
+ public Uri getTLogLoggingUri(){
+ return tlogLoggingUri;
}
public String getUniqueId(){
@@ -274,6 +407,11 @@ public String toString() {
return toString;
}
+ @Override
+ public ConnectionParameter clone(){
+ return new ConnectionParameter(this.connectionType, this.paramsBundle);
+ }
+
@Override
public int describeContents() {
return 0;
@@ -283,13 +421,16 @@ public int describeContents() {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.connectionType);
dest.writeBundle(paramsBundle);
- dest.writeParcelable(this.droneSharePrefs, 0);
+ dest.writeParcelable(tlogLoggingUri, flags);
+ dest.writeLong(eventsDispatchingPeriod);
}
private ConnectionParameter(Parcel in) {
- this.connectionType = in.readInt();
- paramsBundle = in.readBundle();
- this.droneSharePrefs = in.readParcelable(DroneSharePrefs.class.getClassLoader());
+ @ConnectionType.Type int type = in.readInt();
+ this.connectionType = type;
+ paramsBundle = in.readBundle(getClass().getClassLoader());
+ tlogLoggingUri = in.readParcelable(Uri.class.getClassLoader());
+ eventsDispatchingPeriod = in.readLong();
}
public static final Creator CREATOR = new Creator() {
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionType.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionType.java
index ac2468ac48..95d3162288 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionType.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/ConnectionType.java
@@ -1,10 +1,25 @@
package com.o3dr.services.android.lib.drone.connection;
+import android.support.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Contains constants used for the connection parameters.
*/
public class ConnectionType {
+ @IntDef({
+ TYPE_USB,
+ TYPE_UDP,
+ TYPE_TCP,
+ TYPE_BLUETOOTH,
+ TYPE_SOLO
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Type {}
+
/**
* USB connection type
*/
@@ -94,4 +109,25 @@ public class ConnectionType {
*/
public static final String EXTRA_SOLO_LINK_PASSWORD = "extra_solo_link_password";
+ public static String getConnectionTypeLabel(@Type int connectionType){
+ switch (connectionType) {
+ case TYPE_BLUETOOTH:
+ return "bluetooth";
+
+ case TYPE_TCP:
+ return "tcp";
+
+ case TYPE_UDP:
+ return "udp";
+
+ case TYPE_USB:
+ return "usb";
+
+ case TYPE_SOLO:
+ return "solo";
+
+ default:
+ return null;
+ }
+ }
}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/DroneSharePrefs.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/DroneSharePrefs.java
deleted file mode 100644
index 34d2b600af..0000000000
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/connection/DroneSharePrefs.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.o3dr.services.android.lib.drone.connection;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-
-/**
- * Created by fhuya on 11/14/14.
- * @deprecated DroneShare uploads are no longer supported.
- * @since 2.8.0
- */
-public class DroneSharePrefs implements Parcelable {
-
- private final String username;
- private final String password;
- private final boolean isEnabled;
- private final boolean enableLiveUpload;
-
- public DroneSharePrefs(String username, String password, boolean isEnabled, boolean enableLiveUpload) {
- this.username = username;
- this.password = password;
- this.isEnabled = isEnabled;
- this.enableLiveUpload = enableLiveUpload;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public boolean isEnabled() {
- return isEnabled;
- }
-
- public boolean isLiveUploadEnabled() {
- return isEnabled && enableLiveUpload;
- }
-
- public boolean areLoginCredentialsSet(){
- return !TextUtils.isEmpty(username) && !TextUtils.isEmpty(password);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof DroneSharePrefs)) return false;
-
- DroneSharePrefs that = (DroneSharePrefs) o;
-
- if (enableLiveUpload != that.enableLiveUpload) return false;
- if (isEnabled != that.isEnabled) return false;
- if (password != null ? !password.equals(that.password) : that.password != null)
- return false;
- if (username != null ? !username.equals(that.username) : that.username != null)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = username != null ? username.hashCode() : 0;
- result = 31 * result + (password != null ? password.hashCode() : 0);
- result = 31 * result + (isEnabled ? 1 : 0);
- result = 31 * result + (enableLiveUpload ? 1 : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "DroneSharePrefs{" +
- "username='" + username + '\'' +
- ", isEnabled=" + isEnabled +
- ", enableLiveUpload=" + enableLiveUpload +
- '}';
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(this.username);
- dest.writeString(this.password);
- dest.writeByte(isEnabled ? (byte) 1 : (byte) 0);
- dest.writeByte(enableLiveUpload ? (byte) 1 : (byte) 0);
- }
-
- private DroneSharePrefs(Parcel in) {
- this.username = in.readString();
- this.password = in.readString();
- this.isEnabled = in.readByte() != 0;
- this.enableLiveUpload = in.readByte() != 0;
- }
-
- public static final Creator CREATOR = new Creator() {
- public DroneSharePrefs createFromParcel(Parcel source) {
- return new DroneSharePrefs(source);
- }
-
- public DroneSharePrefs[] newArray(int size) {
- return new DroneSharePrefs[size];
- }
- };
-}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/Mission.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/Mission.java
index d7df4be27b..9706fcf0b5 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/Mission.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/Mission.java
@@ -2,12 +2,10 @@
import android.os.Bundle;
import android.os.Parcel;
-import android.os.Parcelable;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -57,6 +55,31 @@ public void setCurrentMissionItem(int currentMissionItem) {
this.currentMissionItem = currentMissionItem;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Mission)) {
+ return false;
+ }
+
+ Mission mission = (Mission) o;
+
+ if (currentMissionItem != mission.currentMissionItem) {
+ return false;
+ }
+ return missionItemsList.equals(mission.missionItemsList);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = currentMissionItem;
+ result = 31 * result + missionItemsList.hashCode();
+ return result;
+ }
+
@Override
public int describeContents() {
return 0;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/action/MissionActions.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/action/MissionActions.java
index e30a873550..c6261340c4 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/action/MissionActions.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/action/MissionActions.java
@@ -24,6 +24,13 @@ private MissionActions(){}
public static final String EXTRA_FORCE_ARM = "extra_force_arm";
public static final String EXTRA_MISSION_SPEED = "extra_mission_speed";
+ public static final String ACTION_SAVE_MISSION = Utils.PACKAGE_NAME + ".action.SAVE_MISSION";
+ public static final String EXTRA_SAVE_MISSION_URI = "extra_save_mission_uri";
+
+ public static final String ACTION_LOAD_MISSION = Utils.PACKAGE_NAME + ".action.LOAD_MISSION";
+ public static final String EXTRA_LOAD_MISSION_URI = "extra_load_mission_uri";
+ public static final String EXTRA_SET_LOADED_MISSION = "extra_set_loaded_mission";
+
public static final String ACTION_LOAD_WAYPOINTS = Utils.PACKAGE_NAME + ".action.LOAD_WAYPOINTS";
public static final String ACTION_BUILD_COMPLEX_MISSION_ITEM = Utils.PACKAGE_NAME + ".action" +
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/MissionItem.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/MissionItem.java
index f4c2fb8b5d..f41e312013 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/MissionItem.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/MissionItem.java
@@ -6,8 +6,6 @@
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
-import java.io.Serializable;
-
/**
* Created by fhuya on 11/5/14.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/StructureScanner.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/StructureScanner.java
index 1c8eba77db..c7364cbe94 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/StructureScanner.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/StructureScanner.java
@@ -32,6 +32,7 @@ public StructureScanner(StructureScanner copy){
copy(copy);
}
+ @Override
public void copy(StructureScanner source){
this.radius = source.radius;
this.heightStep = source.heightStep;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/SurveyDetail.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/SurveyDetail.java
index 6a6e94e34a..0454c3c36e 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/SurveyDetail.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/complex/SurveyDetail.java
@@ -3,8 +3,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import java.io.Serializable;
-
/**
* Created by fhuya on 11/7/14.
*/
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/BaseSpatialItem.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/BaseSpatialItem.java
index a26045f4fe..b04b0de689 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/BaseSpatialItem.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/BaseSpatialItem.java
@@ -14,12 +14,16 @@ public abstract class BaseSpatialItem extends MissionItem implements MissionItem
private LatLongAlt coordinate;
protected BaseSpatialItem(MissionItemType type) {
+ this(type, null);
+ }
+
+ protected BaseSpatialItem(MissionItemType type, LatLongAlt coordinate){
super(type);
+ this.coordinate = coordinate;
}
protected BaseSpatialItem(BaseSpatialItem copy){
- this(copy.getType());
- coordinate = copy.coordinate == null ? null : new LatLongAlt(copy.coordinate);
+ this(copy.getType(), copy.coordinate == null ? null : new LatLongAlt(copy.coordinate));
}
@Override
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Circle.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Circle.java
index 79c339153d..ed54252db3 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Circle.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Circle.java
@@ -2,7 +2,6 @@
import android.os.Parcel;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Land.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Land.java
index fbd83ff574..5f6fb79081 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Land.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Land.java
@@ -12,8 +12,7 @@
public class Land extends BaseSpatialItem implements android.os.Parcelable {
public Land(){
- super(MissionItemType.LAND);
- super.setCoordinate(new LatLongAlt(0.0, 0.0, 0.0));
+ super(MissionItemType.LAND, new LatLongAlt(0.0, 0.0, 0.0));
}
public Land(Land copy){
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/RegionOfInterest.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/RegionOfInterest.java
index a6c0ee486f..07e52afbb8 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/RegionOfInterest.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/RegionOfInterest.java
@@ -2,12 +2,11 @@
import android.os.Parcel;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
/**
- * Points the nose of the vehicle and camera gimbal at the “region of interest”.
+ * Points the nose of the vehicle and camera gimbal at the "region of interest".
* Created by fhuya on 11/6/14.
*/
public class RegionOfInterest extends BaseSpatialItem implements android.os.Parcelable {
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/SplineWaypoint.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/SplineWaypoint.java
index 408e36208b..3a67f512a7 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/SplineWaypoint.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/SplineWaypoint.java
@@ -2,7 +2,6 @@
import android.os.Parcel;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Waypoint.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Waypoint.java
index f1df71ae71..93dbc4990c 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Waypoint.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/mission/item/spatial/Waypoint.java
@@ -2,7 +2,6 @@
import android.os.Parcel;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Battery.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Battery.java
index b41870f507..93c751b316 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Battery.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Battery.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
/**
* Created by fhuya on 10/28/14.
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/CameraProxy.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/CameraProxy.java
index 4fef2a1f14..282bf0be86 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/CameraProxy.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/CameraProxy.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
import com.o3dr.services.android.lib.drone.mission.item.complex.CameraDetail;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/FootPrint.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/FootPrint.java
index 97320f1541..f47f9d19e2 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/FootPrint.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/FootPrint.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.util.MathUtils;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Parameter.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Parameter.java
index d93e78a7a9..08ec729802 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Parameter.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Parameter.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
import java.text.DecimalFormat;
import java.text.ParseException;
@@ -114,14 +113,14 @@ public boolean hasInfo() {
public double[] parseRange() throws ParseException {
final DecimalFormat format = formatter;
- final String[] parts = this.range.split(" ");
- if (parts.length != 2) {
+ final String[] parts = this.range.split("( to |\\s+|-)");
+ if (parts.length < 2) {
throw new IllegalArgumentException();
}
final double[] outRange = new double[2];
- outRange[RANGE_LOW] = format.parse(parts[RANGE_LOW]).doubleValue();
- outRange[RANGE_HIGH] = format.parse(parts[RANGE_HIGH]).doubleValue();
+ outRange[RANGE_LOW] = format.parse(parts[0]).doubleValue();
+ outRange[RANGE_HIGH] = format.parse(parts[outRange.length -1]).doubleValue();
return outRange;
}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/State.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/State.java
index 53e3f0134b..237d5dd0e0 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/State.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/State.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Type.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Type.java
index 814f244d36..1e1675f71b 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Type.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/Type.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
/**
* Stores information about the drone's type.
@@ -20,7 +19,7 @@ public static enum Firmware {
private final String label;
- private Firmware(String label){
+ Firmware(String label){
this.label = label;
}
@@ -38,24 +37,23 @@ public Type(){}
public Type(int droneType, String firmwareVersion){
this.droneType = droneType;
this.firmwareVersion = firmwareVersion;
+ this.firmware = getTypeFirmware(droneType);
+ }
+ private static Firmware getTypeFirmware(int droneType) {
switch(droneType){
case TYPE_COPTER:
- firmware = Firmware.ARDU_COPTER;
- break;
+ return Firmware.ARDU_COPTER;
case TYPE_PLANE:
- firmware = Firmware.ARDU_PLANE;
- break;
+ return Firmware.ARDU_PLANE;
case TYPE_ROVER:
- firmware = Firmware.APM_ROVER;
- break;
+ return Firmware.APM_ROVER;
case TYPE_UNKNOWN:
default:
- firmware = null;
- break;
+ return null;
}
}
@@ -92,14 +90,16 @@ public int describeContents() {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.droneType);
dest.writeString(this.firmwareVersion);
- dest.writeInt(this.firmware == null ? -1 : this.firmware.ordinal());
+
+ // We're no longer passing the firmware ordinal since it'll be inferred from the drone type.
+ dest.writeInt(-1);
}
private Type(Parcel in) {
- this.droneType = in.readInt();
- this.firmwareVersion = in.readString();
- int tmpFirmware = in.readInt();
- this.firmware = tmpFirmware == -1 ? null : Firmware.values()[tmpFirmware];
+ this(in.readInt(), in.readString());
+
+ // Last value is the drone firmware ordinal, which is no longer of use.
+ in.readInt();
}
public static final Creator CREATOR = new Creator() {
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/VehicleMode.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/VehicleMode.java
index dd2b93232d..dda33e2ab0 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/VehicleMode.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/drone/property/VehicleMode.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.drone.property;
import android.os.Parcel;
-import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/gcs/link/LinkConnectionStatus.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/gcs/link/LinkConnectionStatus.java
index e9f1c95980..a3f3bc6ea9 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/gcs/link/LinkConnectionStatus.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/gcs/link/LinkConnectionStatus.java
@@ -7,6 +7,9 @@
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Conveys information about the link connection state.
*
@@ -33,22 +36,30 @@ public final class LinkConnectionStatus implements Parcelable {
*/
public static final String EXTRA_CONNECTION_TIME = "extra_connection_time";
+ /**
+ * The possible status codes that notifies what state the link connection is in.
+ */
@StringDef({
CONNECTED,
CONNECTING,
DISCONNECTED,
FAILED
})
- /**
- * The possible status codes that notifies what state the link connection is in.
- */
+ @Retention(RetentionPolicy.SOURCE)
public @interface StatusCode {
}
+
public static final String CONNECTED = "CONNECTED";
public static final String CONNECTING = "CONNECTING";
public static final String DISCONNECTED = "DISCONNECTED";
public static final String FAILED = "FAILED";
+ /**
+ * The possible failure codes that can be retrieved from the {@link #getExtras()} using key
+ * {@link #EXTRA_ERROR_CODE}. A {@link LinkConnectionStatus.FailureCode}
+ * is guaranteed when {@link #FAILED} occurs.
+ *
+ */
@IntDef({
SYSTEM_UNAVAILABLE,
LINK_UNAVAILABLE,
@@ -58,12 +69,7 @@ public final class LinkConnectionStatus implements Parcelable {
ADDRESS_IN_USE,
UNKNOWN
})
- /**
- * The possible failure codes that can be retrieved from the {@link #getExtras()} using key
- * {@link #EXTRA_ERROR_CODE}. A {@link LinkConnectionStatus.FailureCode}
- * is guaranteed when {@link #FAILED} occurs.
- *
- */
+ @Retention(RetentionPolicy.SOURCE)
public @interface FailureCode {
}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/util/MathUtils.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/MathUtils.java
index bb9dcbb192..0bf46402c7 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/util/MathUtils.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/MathUtils.java
@@ -204,7 +204,7 @@ public static double[][] dcmFromEuler(double roll, double pitch, double yaw) {
* @param epsilon Tolerance for determining list of points for approximation of curve.
* @return List of lat/long points in the approximated curve.
*/
- public static List simplify(List list, double epsilon) {
+ public static List simplify(List extends LatLong> list, double epsilon) {
int index = 0;
double dmax = 0;
int lastIndex = list.size() - 1;
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/util/UriUtils.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/UriUtils.java
new file mode 100644
index 0000000000..a5b646e83a
--- /dev/null
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/UriUtils.java
@@ -0,0 +1,39 @@
+package com.o3dr.services.android.lib.util;
+
+import android.content.Context;
+import android.net.Uri;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Created by fhuya on 8/13/2016.
+ */
+public class UriUtils {
+
+ private UriUtils() {
+ }
+
+ /**
+ * Retrieves an output stream from the given uri.
+ *
+ * @param uri
+ * @return
+ * @since 3.0.0
+ */
+ public static OutputStream getOutputStream(Context context, Uri uri) throws IOException {
+ return context.getContentResolver().openOutputStream(uri);
+ }
+
+ /**
+ * Retrieves an input stream from the given uri.
+ *
+ * @param uri
+ * @return
+ * @since 3.0.0
+ */
+ public static InputStream getInputStream(Context context, Uri uri) throws IOException {
+ return context.getContentResolver().openInputStream(uri);
+ }
+}
diff --git a/ClientLib/src/main/java/com/o3dr/services/android/lib/util/version/VersionUtils.java b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/version/VersionUtils.java
index 74939b8a56..2f7f75016a 100644
--- a/ClientLib/src/main/java/com/o3dr/services/android/lib/util/version/VersionUtils.java
+++ b/ClientLib/src/main/java/com/o3dr/services/android/lib/util/version/VersionUtils.java
@@ -1,7 +1,6 @@
package com.o3dr.services.android.lib.util.version;
import android.content.Context;
-import android.content.pm.PackageManager;
import com.o3dr.android.client.R;
@@ -10,6 +9,10 @@
*/
public class VersionUtils {
+ /**
+ * @param context
+ * @return
+ */
public static int getCoreLibVersion(Context context){
return context.getResources().getInteger(R.integer.core_lib_version);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/api/DPServices.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DPServices.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/api/DPServices.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DPServices.java
index 506008f8d9..a6f16f3ca7 100644
--- a/ServiceApp/src/org/droidplanner/services/android/api/DPServices.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DPServices.java
@@ -1,9 +1,10 @@
-package org.droidplanner.services.android.api;
+package org.droidplanner.services.android.impl.api;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
+import com.o3dr.android.client.BuildConfig;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.gcs.event.GCSEvent;
import com.o3dr.services.android.lib.model.IApiListener;
@@ -11,8 +12,7 @@
import com.o3dr.services.android.lib.model.IDroneApi;
import com.o3dr.services.android.lib.util.version.VersionUtils;
-import org.droidplanner.services.android.BuildConfig;
-import org.droidplanner.services.android.core.drone.DroneManager;
+import org.droidplanner.services.android.impl.core.drone.DroneManager;
import java.util.ArrayList;
import java.util.List;
@@ -59,8 +59,7 @@ public Bundle[] getConnectedApps(String requesterId) throws RemoteException {
DroneManager droneManager = droneApi.getDroneManager();
if(droneManager != null) {
final ConnectionParameter droneParams = droneApi.getDroneManager().getConnectionParameter();
- final ConnectionParameter sanitizedParams = new ConnectionParameter(droneParams.getConnectionType(),
- droneParams.getParamsBundle(), null);
+ final ConnectionParameter sanitizedParams = droneParams.clone();
Bundle info = new Bundle();
info.putString(GCSEvent.EXTRA_APP_ID, droneApi.getOwnerId());
diff --git a/ServiceApp/src/org/droidplanner/services/android/api/DroidPlannerService.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroidPlannerService.java
similarity index 83%
rename from ServiceApp/src/org/droidplanner/services/android/api/DroidPlannerService.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroidPlannerService.java
index 0af1887125..5d803b7e37 100644
--- a/ServiceApp/src/org/droidplanner/services/android/api/DroidPlannerService.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroidPlannerService.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.api;
+package org.droidplanner.services.android.impl.api;
import android.annotation.SuppressLint;
import android.app.Notification;
-import android.app.PendingIntent;
import android.app.Service;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.os.Build;
+import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -14,18 +14,16 @@
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
+import com.o3dr.android.client.R;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.drone.mission.item.complex.CameraDetail;
import com.o3dr.services.android.lib.model.IApiListener;
import com.o3dr.services.android.lib.model.IDroidPlannerServices;
-import org.droidplanner.services.android.DroidPlannerServicesApp;
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.core.drone.DroneManager;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.ui.activity.MainActivity;
-import org.droidplanner.services.android.utils.Utils;
-import org.droidplanner.services.android.utils.file.IO.CameraInfoLoader;
+import org.droidplanner.services.android.impl.core.drone.DroneManager;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.utils.Utils;
+import org.droidplanner.services.android.impl.utils.file.IO.CameraInfoLoader;
import java.util.ArrayList;
import java.util.List;
@@ -34,13 +32,11 @@
import timber.log.Timber;
/**
- * 3DR Services background service implementation.
+ * DroneKit-Android background service implementation.
*/
public class DroidPlannerService extends Service {
- private static final String TAG = DroidPlannerService.class.getName();
-
- /**
+ /**
* Status bar notification id
*/
private static final int FOREGROUND_ID = 101;
@@ -69,7 +65,6 @@ public class DroidPlannerService extends Service {
final ConcurrentHashMap droneManagers = new ConcurrentHashMap<>();
private DPServices dpServices;
- private DroneAccess droneAccess;
private CameraInfoLoader cameraInfoLoader;
private List cachedCameraDetails;
@@ -137,7 +132,7 @@ DroneManager connectDroneManager(ConnectionParameter connParams, String appId, D
}
Timber.d("Drone manager connection for " + appId);
- droneMgr.connect(appId, listener);
+ droneMgr.connect(appId, listener, connParams);
return droneMgr;
}
@@ -200,8 +195,7 @@ public IBinder onBind(Intent intent) {
// Return binder to ipc client-server interaction.
return dpServices;
} else {
- // Return binder to the service.
- return droneAccess;
+ return null;
}
}
@@ -210,14 +204,10 @@ public IBinder onBind(Intent intent) {
public void onCreate() {
super.onCreate();
- final DroidPlannerServicesApp dpApp = (DroidPlannerServicesApp) getApplication();
- dpApp.createFileStartLogging();
-
- Timber.d("Creating 3DR Services.");
+ Timber.d("Creating DroneKit-Android.");
final Context context = getApplicationContext();
- droneAccess = new DroneAccess(this);
dpServices = new DPServices(this);
lbm = LocalBroadcastManager.getInstance(context);
this.cameraInfoLoader = new CameraInfoLoader(context);
@@ -231,19 +221,13 @@ private void updateForegroundNotification() {
//Put the service in the foreground
final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context)
- .setContentTitle("3DR Services")
+ .setContentTitle("DroneKit-Android")
.setPriority(NotificationCompat.PRIORITY_MIN)
- .setSmallIcon(R.drawable.ic_stat_notify)
- .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context,
- MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0));
+ .setSmallIcon(R.drawable.ic_stat_notify);
final int connectedCount = droneApiStore.size();
- if (connectedCount > 0) {
- if (connectedCount == 1) {
- notifBuilder.setContentText("1 connected app");
- } else {
- notifBuilder.setContentText(connectedCount + " connected apps");
- }
+ if (connectedCount > 1) {
+ notifBuilder.setContentText(connectedCount + " connected apps");
}
final Notification notification = notifBuilder.build();
@@ -253,7 +237,7 @@ private void updateForegroundNotification() {
@Override
public void onDestroy() {
super.onDestroy();
- Timber.d("Destroying 3DR Services.");
+ Timber.d("Destroying DroneKit-Android.");
for (DroneApi droneApi : droneApiStore.values()) {
droneApi.destroy();
@@ -269,8 +253,8 @@ public void onDestroy() {
stopForeground(true);
- final DroidPlannerServicesApp dpApp = (DroidPlannerServicesApp) getApplication();
- dpApp.closeLogFile();
+ //Disable this service. It'll be reenabled the next time its local client needs it.
+ enableDroidPlannerService(getApplicationContext(), false);
}
@Override
@@ -290,4 +274,17 @@ public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}
+ /**
+ * Toggles the DroidPlannerService component
+ * @param context
+ * @param enable
+ */
+ public static void enableDroidPlannerService(Context context, boolean enable){
+ final ComponentName serviceComp = new ComponentName(context, DroidPlannerService.class);
+ final int newState = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+
+ context.getPackageManager().setComponentEnabledSetting(serviceComp, newState, PackageManager.DONT_KILL_APP);
+ }
+
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/api/DroneApi.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroneApi.java
similarity index 81%
rename from ServiceApp/src/org/droidplanner/services/android/api/DroneApi.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroneApi.java
index c3b30e17bd..0200ad0599 100644
--- a/ServiceApp/src/org/droidplanner/services/android/api/DroneApi.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/api/DroneApi.java
@@ -1,9 +1,12 @@
-package org.droidplanner.services.android.api;
+package org.droidplanner.services.android.impl.api;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
+import android.os.Looper;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Pair;
@@ -12,8 +15,8 @@
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.ardupilotmega.msg_mag_cal_progress;
import com.MAVLink.ardupilotmega.msg_mag_cal_report;
-import com.o3dr.services.android.lib.drone.action.CameraActions;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
+import com.o3dr.services.android.lib.drone.action.CameraActions;
import com.o3dr.services.android.lib.drone.action.ConnectionActions;
import com.o3dr.services.android.lib.drone.action.ExperimentalActions;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
@@ -21,7 +24,6 @@
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
-import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
import com.o3dr.services.android.lib.drone.mission.Mission;
import com.o3dr.services.android.lib.drone.mission.action.MissionActions;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
@@ -42,24 +44,31 @@
import com.o3dr.services.android.lib.model.IObserver;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.communication.connection.SoloConnection;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneManager;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.exception.ConnectionException;
-import org.droidplanner.services.android.utils.CommonApiUtils;
-import org.droidplanner.services.android.utils.video.VideoManager;
+import org.droidplanner.services.android.impl.communication.connection.SoloConnection;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.AccelCalibration;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.exception.ConnectionException;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.utils.MissionUtils;
+import org.droidplanner.services.android.impl.utils.video.VideoManager;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentLinkedQueue;
import timber.log.Timber;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.ACTION_SET_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_MISSION;
+import static com.o3dr.services.android.lib.drone.mission.action.MissionActions.EXTRA_PUSH_TO_DRONE;
+
/**
* Implementation for the IDroneApi interface.
*/
@@ -69,7 +78,36 @@ public final class DroneApi extends IDroneApi.Stub implements DroneInterfaces.On
//The Reset ROI mission item was introduced in version 2.6.8. Any client library older than this do not support it.
private final static int RESET_ROI_LIB_VERSION = 206080;
+ private final Runnable eventsDispatcher = new Runnable() {
+ private final LinkedHashMap eventsFilter = new LinkedHashMap<>();
+
+ @Override
+ public void run() {
+ eventsFilter.clear();
+ //Go through the events buffer and empty it
+ EventInfo eventInfo = eventsBuffer.poll();
+ while(eventInfo != null) {
+ eventsFilter.put(eventInfo.event, eventInfo.extras);
+ EventInfo.recycle(eventInfo);
+
+ eventInfo = eventsBuffer.poll();
+ }
+
+ for(Map.Entry entry : eventsFilter.entrySet()){
+ dispatchAttributeEvent(entry.getKey(), entry.getValue());
+ }
+
+ eventsFilter.clear();
+
+ handler.removeCallbacks(this);
+ if(isEventsBufferingEnabled()) {
+ handler.postDelayed(this, connectionParams.getEventsDispatchingPeriod());
+ }
+ }
+ };
+
private final Context context;
+ private final Handler handler;
private final ConcurrentLinkedQueue observersList;
private final ConcurrentLinkedQueue mavlinkObserversList;
@@ -81,12 +119,15 @@ public final class DroneApi extends IDroneApi.Stub implements DroneInterfaces.On
private final DroidPlannerService service;
+ private final ConcurrentLinkedQueue eventsBuffer = new ConcurrentLinkedQueue<>();
+
private ConnectionParameter connectionParams;
DroneApi(DroidPlannerService dpService, IApiListener listener, String ownerId) {
this.service = dpService;
this.context = dpService.getApplicationContext();
+ handler = new Handler(Looper.getMainLooper());
this.ownerId = ownerId;
@@ -140,6 +181,10 @@ private Drone getDrone() {
return this.droneMgr.getDrone();
}
+ private boolean isEventsBufferingEnabled(){
+ return connectionParams != null && connectionParams.getEventsDispatchingPeriod() > 0L;
+ }
+
@Override
public Bundle getAttribute(String type) throws RemoteException {
Bundle carrier = new Bundle();
@@ -190,7 +235,7 @@ private ConnectionParameter checkConnectionParameter(ConnectionParameter connPar
}
if (SoloConnection.isUdpSoloConnection(context, connParams)) {
- ConnectionParameter update = SoloConnection.getSoloConnectionParameterFromUdp(context);
+ ConnectionParameter update = SoloConnection.getSoloConnectionParameterFromUdp(context, connParams);
if (update != null) {
return update;
}
@@ -219,6 +264,11 @@ public void connect(ConnectionParameter connParams) {
this.connectionParams = connParams;
this.droneMgr = service.connectDroneManager(this.connectionParams, ownerId, this);
+
+ if(isEventsBufferingEnabled()) {
+ eventsBuffer.clear();
+ handler.postDelayed(eventsDispatcher, this.connectionParams.getEventsDispatchingPeriod());
+ }
}
} catch (ConnectionException e) {
LinkConnectionStatus connectionStatus = LinkConnectionStatus
@@ -233,6 +283,8 @@ public void disconnect() {
this.connectionParams = null;
this.droneMgr = null;
+ handler.removeCallbacks(eventsDispatcher);
+
}
private void checkForSelfRelease() {
@@ -350,6 +402,37 @@ public void executeAction(Action action, ICommandListener listener) throws Remot
}
break;
+ case MissionActions.ACTION_SAVE_MISSION: {
+ Mission mission = data.getParcelable(MissionActions.EXTRA_MISSION);
+ Uri saveUri = data.getParcelable(MissionActions.EXTRA_SAVE_MISSION_URI);
+ if (saveUri == null) {
+ CommonApiUtils.postErrorEvent(CommandExecutionError.COMMAND_FAILED, listener);
+ } else {
+ MissionUtils.saveMission(context, mission, saveUri, listener);
+ }
+ break;
+ }
+
+ case MissionActions.ACTION_LOAD_MISSION: {
+ Uri loadUri = data.getParcelable(MissionActions.EXTRA_LOAD_MISSION_URI);
+ boolean setMission = data.getBoolean(MissionActions.EXTRA_SET_LOADED_MISSION, false);
+ if (loadUri != null) {
+ Mission mission = MissionUtils.loadMission(context, loadUri);
+ if(mission != null){
+ // Going back to the caller.
+ data.putParcelable(MissionActions.EXTRA_MISSION, mission);
+
+ if(setMission){
+ Bundle params = new Bundle();
+ params.putParcelable(EXTRA_MISSION, mission);
+ params.putBoolean(EXTRA_PUSH_TO_DRONE, false);
+ executeAction(new Action(ACTION_SET_MISSION, params), listener);
+ }
+ }
+ }
+ break;
+ }
+
default:
if (droneMgr != null) {
droneMgr.executeAsyncAction(clientInfo, action, listener);
@@ -386,21 +469,31 @@ private void notifyAttributeUpdate(List> attributesInfo) {
}
private void notifyAttributeUpdate(String attributeEvent, Bundle extrasBundle) {
- if (observersList.isEmpty()) {
+ if (observersList.isEmpty() || attributeEvent == null) {
return;
}
- if (attributeEvent != null) {
- for (IObserver observer : observersList) {
+ if(AttributeEvent.STATE_CONNECTED.equals(attributeEvent) ||
+ AttributeEvent.STATE_DISCONNECTED.equals(attributeEvent) ||
+ !isEventsBufferingEnabled()){
+ //Dispatch the event immediately
+ dispatchAttributeEvent(attributeEvent, extrasBundle);
+ }
+ else{
+ eventsBuffer.add(EventInfo.obtain(attributeEvent, extrasBundle));
+ }
+ }
+
+ private void dispatchAttributeEvent(String attributeEvent, Bundle extrasBundle){
+ for (IObserver observer : observersList) {
+ try {
+ observer.onAttributeUpdated(attributeEvent, extrasBundle);
+ } catch (RemoteException e) {
+ Timber.e(e, e.getMessage());
try {
- observer.onAttributeUpdated(attributeEvent, extrasBundle);
- } catch (RemoteException e) {
- Timber.e(e, e.getMessage());
- try {
- removeAttributesObserver(observer);
- } catch (RemoteException e1) {
- Timber.e(e, e1.getMessage());
- }
+ removeAttributesObserver(observer);
+ } catch (RemoteException e1) {
+ Timber.e(e, e1.getMessage());
}
}
}
@@ -440,7 +533,7 @@ public ClientInfo getClientInfo() {
}
@Override
- public void onAttributeEvent(String attributeEvent, Bundle eventInfo, boolean checkForSololinkApi) {
+ public void onAttributeEvent(String attributeEvent, Bundle eventInfo) {
if (TextUtils.isEmpty(attributeEvent)) {
return;
}
@@ -468,6 +561,9 @@ public void onDroneEvent(DroneInterfaces.DroneEventsType event, Drone drone) {
.putExtra(GCSEvent.EXTRA_APP_ID, ownerId));
droneEvent = AttributeEvent.STATE_DISCONNECTED;
+
+ //Empty the event buffer queue
+ eventsBuffer.clear();
break;
case GUIDEDPOINT:
@@ -581,8 +677,7 @@ public void onDroneEvent(DroneInterfaces.DroneEventsType event, Drone drone) {
case CONNECTED:
//Broadcast the vehicle connection.
- ConnectionParameter sanitizedParameter = new ConnectionParameter(connectionParams
- .getConnectionType(), connectionParams.getParamsBundle());
+ ConnectionParameter sanitizedParameter = connectionParams.clone();
context.sendBroadcast(new Intent(GCSEvent.ACTION_VEHICLE_CONNECTION)
.putExtra(GCSEvent.EXTRA_APP_ID, ownerId)
@@ -683,11 +778,8 @@ public void onConnectionStatus(LinkConnectionStatus connectionStatus) {
case LinkConnectionStatus.FAILED:
disconnect();
checkForSelfRelease();
-
- //This is to ensure backwards compatibility
- // TODO: remove this in version 3.0
- notifyConnectionFailed(connectionStatus);
break;
+
case LinkConnectionStatus.DISCONNECTED:
disconnect();
checkForSelfRelease();
@@ -700,22 +792,6 @@ public void onConnectionStatus(LinkConnectionStatus connectionStatus) {
}
- private void notifyConnectionFailed(LinkConnectionStatus connectionStatus) {
- Bundle extras = connectionStatus.getExtras();
- String msg = null;
- if (extras != null) {
- msg = extras.getString(LinkConnectionStatus.EXTRA_ERROR_MSG);
- }
-
- ConnectionResult connectionResult = new ConnectionResult(0, msg);
- try {
- apiListener.onConnectionFailed(connectionResult);
- } catch (RemoteException e) {
- Timber.w(e, "Unable to forward connection fail to client.");
- }
-
- }
-
@Override
public void binderDied() {
checkForSelfRelease();
@@ -756,4 +832,31 @@ public ClientInfo(String appId, int apiVersionCode, int clientVersionCode) {
this.clientVersionCode = clientVersionCode;
}
}
+
+ private static class EventInfo {
+
+ private static final ConcurrentLinkedQueue sPool = new ConcurrentLinkedQueue<>();
+
+ String event;
+ Bundle extras;
+
+ static EventInfo obtain(String event, Bundle extras){
+ EventInfo eventInfo = sPool.poll();
+ if(eventInfo == null){
+ eventInfo = new EventInfo();
+ }
+
+ eventInfo.event = event;
+ eventInfo.extras = extras;
+ return eventInfo;
+ }
+
+ static void recycle(EventInfo eventInfo){
+ if(eventInfo != null) {
+ eventInfo.event = null;
+ eventInfo.extras = null;
+ sPool.offer(eventInfo);
+ }
+ }
+ }
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidIpConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidIpConnection.java
similarity index 65%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidIpConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidIpConnection.java
index ea1af2a85b..93c692495e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidIpConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidIpConnection.java
@@ -1,8 +1,9 @@
-package org.droidplanner.services.android.communication.connection;
+package org.droidplanner.services.android.impl.communication.connection;
import android.content.Context;
+import android.os.Bundle;
-import org.droidplanner.services.android.utils.connection.WifiConnectionHandler;
+import org.droidplanner.services.android.impl.utils.connection.WifiConnectionHandler;
import java.io.IOException;
@@ -13,24 +14,20 @@ public abstract class AndroidIpConnection extends AndroidMavLinkConnection {
private final WifiConnectionHandler wifiHandler;
- public AndroidIpConnection(Context applicationContext) {
- this(applicationContext, null);
- }
-
protected AndroidIpConnection(Context context, WifiConnectionHandler wifiHandler){
super(context);
this.wifiHandler = wifiHandler;
}
@Override
- protected final void openConnection() throws IOException {
+ protected final void openConnection(Bundle connectionExtras) throws IOException {
if(this.wifiHandler != null) {
this.wifiHandler.start();
}
- onOpenConnection();
+ onOpenConnection(connectionExtras);
}
- protected abstract void onOpenConnection() throws IOException;
+ protected abstract void onOpenConnection(Bundle extras) throws IOException;
@Override
protected final void closeConnection() throws IOException {
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidMavLinkConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidMavLinkConnection.java
new file mode 100644
index 0000000000..43c4a8878a
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidMavLinkConnection.java
@@ -0,0 +1,20 @@
+package org.droidplanner.services.android.impl.communication.connection;
+
+import android.content.Context;
+
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnection;
+import org.droidplanner.services.android.impl.core.model.Logger;
+import org.droidplanner.services.android.impl.utils.AndroidLogger;
+
+public abstract class AndroidMavLinkConnection extends MavLinkConnection {
+
+
+ public AndroidMavLinkConnection(Context applicationContext) {
+ super(applicationContext);
+ }
+
+ @Override
+ protected final Logger initLogger() {
+ return AndroidLogger.getLogger();
+ }
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidTcpConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidTcpConnection.java
similarity index 75%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidTcpConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidTcpConnection.java
index 54b37879e4..b7954ccebb 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidTcpConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidTcpConnection.java
@@ -1,12 +1,13 @@
-package org.droidplanner.services.android.communication.connection;
+package org.droidplanner.services.android.impl.communication.connection;
import android.content.Context;
+import android.os.Bundle;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.core.MAVLink.connection.TcpConnection;
-import org.droidplanner.services.android.core.model.Logger;
-import org.droidplanner.services.android.utils.connection.WifiConnectionHandler;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.TcpConnection;
+import org.droidplanner.services.android.impl.core.model.Logger;
+import org.droidplanner.services.android.impl.utils.connection.WifiConnectionHandler;
import java.io.IOException;
@@ -23,7 +24,7 @@ public AndroidTcpConnection(Context context, String tcpServerIp, int tcpServerPo
this.serverIp = tcpServerIp;
this.serverPort = tcpServerPort;
- mConnectionImpl = new TcpConnection() {
+ mConnectionImpl = new TcpConnection(context) {
@Override
protected int loadServerPort() {
return serverPort;
@@ -40,8 +41,8 @@ protected Logger initLogger() {
}
@Override
- protected void onConnectionOpened() {
- AndroidTcpConnection.this.onConnectionOpened();
+ protected void onConnectionOpened(Bundle extras) {
+ AndroidTcpConnection.this.onConnectionOpened(extras);
}
@Override
@@ -66,8 +67,8 @@ protected void loadPreferences() {
}
@Override
- protected void onOpenConnection() throws IOException {
- mConnectionImpl.openConnection();
+ protected void onOpenConnection(Bundle extras) throws IOException {
+ mConnectionImpl.openConnection(extras);
}
@Override
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidUdpConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidUdpConnection.java
similarity index 87%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidUdpConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidUdpConnection.java
index 98103e94b3..c23d886ab8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidUdpConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/AndroidUdpConnection.java
@@ -1,13 +1,14 @@
-package org.droidplanner.services.android.communication.connection;
+package org.droidplanner.services.android.impl.communication.connection;
import android.content.Context;
+import android.os.Bundle;
import android.util.Log;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.core.MAVLink.connection.UdpConnection;
-import org.droidplanner.services.android.core.model.Logger;
-import org.droidplanner.services.android.utils.connection.WifiConnectionHandler;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.UdpConnection;
+import org.droidplanner.services.android.impl.core.model.Logger;
+import org.droidplanner.services.android.impl.utils.connection.WifiConnectionHandler;
import java.io.IOException;
import java.net.InetAddress;
@@ -31,7 +32,7 @@ public AndroidUdpConnection(Context context, int udpServerPort, WifiConnectionHa
super(context, wifiHandler);
this.serverPort = udpServerPort;
- mConnectionImpl = new UdpConnection() {
+ mConnectionImpl = new UdpConnection(context) {
@Override
protected int loadServerPort() {
return serverPort;
@@ -43,8 +44,8 @@ protected Logger initLogger() {
}
@Override
- protected void onConnectionOpened() {
- AndroidUdpConnection.this.onConnectionOpened();
+ protected void onConnectionOpened(Bundle extras) {
+ AndroidUdpConnection.this.onConnectionOpened(extras);
}
@Override
@@ -88,9 +89,9 @@ protected void loadPreferences() {
}
@Override
- protected void onOpenConnection() throws IOException {
+ protected void onOpenConnection(Bundle extras) throws IOException {
Log.d(TAG, "Opening udp connection");
- mConnectionImpl.openConnection();
+ mConnectionImpl.openConnection(extras);
if (pingRunner == null || pingRunner.isShutdown())
pingRunner = Executors.newSingleThreadScheduledExecutor();
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/BluetoothConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/BluetoothConnection.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/BluetoothConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/BluetoothConnection.java
index 99ddfd4ba1..807cb75f0c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/BluetoothConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/BluetoothConnection.java
@@ -1,14 +1,15 @@
-package org.droidplanner.services.android.communication.connection;
+package org.droidplanner.services.android.impl.communication.connection;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
+import android.os.Bundle;
import android.os.ParcelUuid;
import android.util.Log;
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnectionTypes;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnectionTypes;
import java.io.IOException;
import java.io.InputStream;
@@ -38,7 +39,7 @@ public BluetoothConnection(Context parentContext, String btAddress) {
}
@Override
- protected void openConnection() throws IOException {
+ protected void openConnection(Bundle connectionExtras) throws IOException {
Log.d(BLUE, "Connect");
// Reset the bluetooth connection
@@ -74,7 +75,7 @@ protected void openConnection() throws IOException {
out = bluetoothSocket.getOutputStream();
in = bluetoothSocket.getInputStream();
- onConnectionOpened();
+ onConnectionOpened(connectionExtras);
}
@SuppressLint("NewApi")
@@ -90,7 +91,6 @@ private BluetoothDevice findSerialBluetoothBoard() throws UnknownHostException {
final ParcelUuid[] deviceUuids = device.getUuids();
if (deviceUuids != null && deviceUuids.length > 0) {
for (ParcelUuid id : device.getUuids()) {
- // TODO maybe this will not work on newer devices
Log.d(BLUE, "id:" + id.toString());
if (id.toString().equalsIgnoreCase(UUID_SPP_DEVICE)) {
Log.d(BLUE,
@@ -149,6 +149,5 @@ private void resetConnection() throws IOException {
@Override
protected void loadPreferences() {
- // TODO Auto-generated method stub
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/SoloConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/SoloConnection.java
similarity index 85%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/SoloConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/SoloConnection.java
index cee0bbdee6..8ca911cea7 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/SoloConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/SoloConnection.java
@@ -1,6 +1,7 @@
-package org.droidplanner.services.android.communication.connection;
+package org.droidplanner.services.android.impl.communication.connection;
import android.content.Context;
+import android.net.Uri;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -10,9 +11,10 @@
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.utils.connection.WifiConnectionHandler;
+import org.droidplanner.services.android.impl.utils.connection.WifiConnectionHandler;
import java.io.IOException;
+import java.sql.Connection;
import java.util.List;
import timber.log.Timber;
@@ -39,8 +41,8 @@ public SoloConnection(Context applicationContext, String soloLinkId, String pass
this.soloLinkPassword = password;
this.dataLink = new AndroidUdpConnection(applicationContext, SOLO_UDP_PORT) {
@Override
- protected void onConnectionOpened() {
- SoloConnection.this.onConnectionOpened();
+ protected void onConnectionOpened(Bundle extras) {
+ SoloConnection.this.onConnectionOpened(extras);
}
@Override
@@ -51,7 +53,7 @@ protected void onConnectionStatus(LinkConnectionStatus connectionStatus) {
}
@Override
- protected void openConnection() throws IOException {
+ protected void openConnection(Bundle connectionExtras) throws IOException {
if (TextUtils.isEmpty(soloLinkId)) {
LinkConnectionStatus connectionStatus = LinkConnectionStatus
.newFailedConnectionStatus(LinkConnectionStatus.INVALID_CREDENTIALS, "Invalid connection credentials!");
@@ -97,13 +99,13 @@ public int getConnectionType() {
}
@Override
- public void onWifiConnected(String wifiSsid) {
+ public void onWifiConnected(String wifiSsid, Bundle extras) {
if (isConnecting()) {
//Let's see if we're connected to our target wifi
if (wifiSsid.equalsIgnoreCase(soloLinkId)) {
//We're good to go
try {
- dataLink.openConnection();
+ dataLink.openConnection(extras);
} catch (IOException e) {
reportIOException(e);
Timber.e(e, e.getMessage());
@@ -151,7 +153,14 @@ private void checkScanResults(List results) {
if (targetResult != null) {
//We're good to go
try {
- int connectionResult = wifiHandler.connectToWifi(targetResult, soloLinkPassword);
+ Bundle connectInfo = new Bundle();
+ Bundle extras = getConnectionExtras();
+ if (extras != null && !extras.isEmpty()) {
+ connectInfo.putAll(extras);
+ }
+ connectInfo.putParcelable(WifiConnectionHandler.EXTRA_SCAN_RESULT, targetResult);
+ connectInfo.putString(WifiConnectionHandler.EXTRA_SSID_PASSWORD, soloLinkPassword);
+ int connectionResult = wifiHandler.connectToWifi(connectInfo);
if (connectionResult != 0) {
@LinkConnectionStatus.FailureCode int failureCode = connectionResult;
LinkConnectionStatus connectionStatus = LinkConnectionStatus
@@ -193,13 +202,13 @@ public static boolean isUdpSoloConnection(Context context, ConnectionParameter c
}
}
- public static ConnectionParameter getSoloConnectionParameterFromUdp(Context context){
+ public static ConnectionParameter getSoloConnectionParameterFromUdp(Context context, ConnectionParameter udpConnectionParameters){
if(context == null)
return null;
final String wifiSsid = WifiConnectionHandler.getCurrentWifiLink((WifiManager) context.getSystemService(Context.WIFI_SERVICE));
if(WifiConnectionHandler.isSoloWifi(wifiSsid)){
- return ConnectionParameter.newSoloConnection(wifiSsid, null);
+ return ConnectionParameter.newSoloConnection(wifiSsid, null, udpConnectionParameters.getTLogLoggingUri(), udpConnectionParameters.getEventsDispatchingPeriod());
}
return null;
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbCDCConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbCDCConnection.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbCDCConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbCDCConnection.java
index ca48297c77..b75eae65fd 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbCDCConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbCDCConnection.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.communication.connection.usb;
+package org.droidplanner.services.android.impl.communication.connection.usb;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -7,10 +7,12 @@
import android.content.IntentFilter;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
+import android.os.Bundle;
import android.util.Log;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialProber;
+
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import java.io.IOException;
@@ -44,7 +46,7 @@ public void onReceive(Context context, Intent intent) {
if (device != null) {
//call method to set up device communication
try {
- openUsbDevice(device);
+ openUsbDevice(device, extrasHolder.get());
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
@@ -75,6 +77,7 @@ public void run() {
}
};
+ private final AtomicReference extrasHolder = new AtomicReference<>();
private ScheduledExecutorService scheduler;
protected UsbCDCConnection(Context context, UsbConnection parentConn, int baudRate) {
@@ -102,7 +105,8 @@ private void removeWatchdog() {
}
@Override
- protected void openUsbConnection() throws IOException {
+ protected void openUsbConnection(Bundle extras) throws IOException {
+ extrasHolder.set(extras);
registerUsbPermissionBroadcastReceiver();
// Get UsbManager from Android.
@@ -118,7 +122,7 @@ protected void openUsbConnection() throws IOException {
//Pick the first device
UsbDevice device = availableDevices.get(0);
if (manager.hasPermission(device)) {
- openUsbDevice(device);
+ openUsbDevice(device, extras);
} else {
removeWatchdog();
@@ -129,7 +133,7 @@ protected void openUsbConnection() throws IOException {
}
}
- private void openUsbDevice(UsbDevice device) throws IOException {
+ private void openUsbDevice(UsbDevice device, Bundle extras) throws IOException {
// Get UsbManager from Android.
UsbManager manager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
@@ -147,7 +151,7 @@ private void openUsbDevice(UsbDevice device) throws IOException {
serialDriverRef.set(serialDriver);
- onUsbConnectionOpened();
+ onUsbConnectionOpened(extras);
} catch (IOException e) {
Log.e(TAG, "Error setting up device: " + e.getMessage(), e);
try {
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbConnection.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbConnection.java
index 00e389ce69..4cc26490b1 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbConnection.java
@@ -1,16 +1,17 @@
-package org.droidplanner.services.android.communication.connection.usb;
+package org.droidplanner.services.android.impl.communication.connection.usb;
import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
+import android.os.Bundle;
import android.util.Log;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.communication.connection.AndroidMavLinkConnection;
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnectionTypes;
-import org.droidplanner.services.android.core.model.Logger;
-import org.droidplanner.services.android.utils.AndroidLogger;
+import org.droidplanner.services.android.impl.communication.connection.AndroidMavLinkConnection;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnectionTypes;
+import org.droidplanner.services.android.impl.core.model.Logger;
+import org.droidplanner.services.android.impl.utils.AndroidLogger;
import java.io.IOException;
import java.util.HashMap;
@@ -43,10 +44,10 @@ protected void loadPreferences() {
}
@Override
- protected void openConnection() throws IOException {
+ protected void openConnection(Bundle connectionExtras) throws IOException {
if (mUsbConnection != null) {
try {
- mUsbConnection.openUsbConnection();
+ mUsbConnection.openUsbConnection(connectionExtras);
Log.d(TAG, "Reusing previous usb connection.");
return;
} catch (IOException e) {
@@ -55,10 +56,10 @@ protected void openConnection() throws IOException {
}
}
- if (isFTDIdevice(mContext)) {
- final UsbConnectionImpl tmp = new UsbFTDIConnection(mContext, this, mBaudRate);
+ if (isFTDIdevice(context)) {
+ final UsbConnectionImpl tmp = new UsbFTDIConnection(context, this, mBaudRate);
try {
- tmp.openUsbConnection();
+ tmp.openUsbConnection(connectionExtras);
// If the call above is successful, 'mUsbConnection' will be set.
mUsbConnection = tmp;
@@ -71,10 +72,10 @@ protected void openConnection() throws IOException {
// Fallback
if (mUsbConnection == null) {
- final UsbConnectionImpl tmp = new UsbCDCConnection(mContext, this, mBaudRate);
+ final UsbConnectionImpl tmp = new UsbCDCConnection(context, this, mBaudRate);
// If an error happens here, let it propagate up the call chain since this is the fallback.
- tmp.openUsbConnection();
+ tmp.openUsbConnection(connectionExtras);
mUsbConnection = tmp;
Log.d(TAG, "Using open-source usb connection.");
}
@@ -139,8 +140,8 @@ protected UsbConnectionImpl(Context context, UsbConnection parentConn, int baudR
mBaudRate = baudRate;
}
- protected void onUsbConnectionOpened() {
- parentConnection.onConnectionOpened();
+ protected void onUsbConnectionOpened(Bundle extras) {
+ parentConnection.onConnectionOpened(extras);
}
protected void onUsbConnectionStatus(LinkConnectionStatus connectionStatus) {
@@ -149,7 +150,7 @@ protected void onUsbConnectionStatus(LinkConnectionStatus connectionStatus) {
protected abstract void closeUsbConnection() throws IOException;
- protected abstract void openUsbConnection() throws IOException;
+ protected abstract void openUsbConnection(Bundle extras) throws IOException;
protected abstract int readDataBlock(byte[] readData) throws IOException;
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbFTDIConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbFTDIConnection.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbFTDIConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbFTDIConnection.java
index ae628d6e7b..841627dcd4 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/usb/UsbFTDIConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/connection/usb/UsbFTDIConnection.java
@@ -1,14 +1,15 @@
-package org.droidplanner.services.android.communication.connection.usb;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicReference;
+package org.droidplanner.services.android.impl.communication.connection.usb;
import android.content.Context;
+import android.os.Bundle;
import android.util.Log;
import com.ftdi.j2xx.D2xxManager;
import com.ftdi.j2xx.FT_Device;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicReference;
+
class UsbFTDIConnection extends UsbConnection.UsbConnectionImpl {
private static final String TAG = UsbFTDIConnection.class.getSimpleName();
@@ -22,7 +23,7 @@ protected UsbFTDIConnection(Context context, UsbConnection parentConn, int baudR
}
@Override
- protected void openUsbConnection() throws IOException {
+ protected void openUsbConnection(Bundle extras) throws IOException {
D2xxManager ftD2xx = null;
try {
ftD2xx = D2xxManager.getInstance(mContext);
@@ -70,7 +71,7 @@ protected void openUsbConnection() throws IOException {
ftDevRef.set(ftDev);
- onUsbConnectionOpened();
+ onUsbConnectionOpened(extras);
}
@Override
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/model/DataLink.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/model/DataLink.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/communication/model/DataLink.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/model/DataLink.java
index 62ac365510..2a9d409b76 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/model/DataLink.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/model/DataLink.java
@@ -1,4 +1,6 @@
-package org.droidplanner.services.android.communication.model;
+package org.droidplanner.services.android.impl.communication.model;
+
+import android.os.Bundle;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.model.ICommandListener;
@@ -15,6 +17,8 @@ public interface DataLinkProvider {
void closeConnection();
+ Bundle getConnectionExtras();
+
}
public interface DataLinkListener {
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/service/MAVLinkClient.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/service/MAVLinkClient.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/communication/service/MAVLinkClient.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/service/MAVLinkClient.java
index a646e9b893..e6a904c2e2 100644
--- a/ServiceApp/src/org/droidplanner/services/android/communication/service/MAVLinkClient.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/communication/service/MAVLinkClient.java
@@ -1,38 +1,31 @@
-package org.droidplanner.services.android.communication.service;
+package org.droidplanner.services.android.impl.communication.service;
import android.content.Context;
+import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.MAVLink.MAVLinkPacket;
import com.MAVLink.Messages.MAVLinkMessage;
-import com.google.android.gms.analytics.HitBuilders;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.communication.connection.AndroidMavLinkConnection;
-import org.droidplanner.services.android.communication.connection.AndroidTcpConnection;
-import org.droidplanner.services.android.communication.connection.AndroidUdpConnection;
-import org.droidplanner.services.android.communication.connection.BluetoothConnection;
-import org.droidplanner.services.android.communication.connection.SoloConnection;
-import org.droidplanner.services.android.communication.connection.usb.UsbConnection;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnection;
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnectionListener;
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnectionTypes;
-import org.droidplanner.services.android.core.drone.manager.DroneCommandTracker;
-import org.droidplanner.services.android.data.SessionDB;
-import org.droidplanner.services.android.utils.analytics.GAUtils;
-import org.droidplanner.services.android.utils.connection.WifiConnectionHandler;
-import org.droidplanner.services.android.utils.file.DirectoryPath;
-import org.droidplanner.services.android.utils.file.FileUtils;
-
-import java.io.File;
+import org.droidplanner.services.android.impl.communication.connection.AndroidMavLinkConnection;
+import org.droidplanner.services.android.impl.communication.connection.AndroidTcpConnection;
+import org.droidplanner.services.android.impl.communication.connection.AndroidUdpConnection;
+import org.droidplanner.services.android.impl.communication.connection.BluetoothConnection;
+import org.droidplanner.services.android.impl.communication.connection.SoloConnection;
+import org.droidplanner.services.android.impl.communication.connection.usb.UsbConnection;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnection;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnectionListener;
+import org.droidplanner.services.android.impl.core.drone.manager.DroneCommandTracker;
+import org.droidplanner.services.android.impl.utils.connection.WifiConnectionHandler;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.Date;
import timber.log.Timber;
@@ -44,8 +37,6 @@ public class MAVLinkClient implements DataLink.DataLinkProvider
private static final int DEFAULT_SYS_ID = 255;
private static final int DEFAULT_COMP_ID = 190;
- private static final String TLOG_PREFIX = "log";
-
/**
* Maximum possible sequence number for a packet.
*/
@@ -66,16 +57,6 @@ public void onConnectionStatus(final LinkConnectionStatus connectionStatus) {
case LinkConnectionStatus.DISCONNECTED:
closeConnection();
break;
-
- case LinkConnectionStatus.CONNECTED:
- Bundle extras = connectionStatus.getExtras();
- if (extras != null) {
- long connectionTime = extras.getLong(LinkConnectionStatus.EXTRA_CONNECTION_TIME);
- if (connectionTime != 0) {
- startLoggingThread(connectionTime);
- }
- }
- break;
}
}
};
@@ -83,7 +64,6 @@ public void onConnectionStatus(final LinkConnectionStatus connectionStatus) {
private AndroidMavLinkConnection mavlinkConn;
private final DataLink.DataLinkListener listener;
- private final SessionDB sessionDB;
private final Context context;
private int packetSeqNumber = 0;
@@ -101,8 +81,6 @@ public MAVLinkClient(Context context, DataLink.DataLinkListener l
}
this.connParams = connParams;
- this.sessionDB = new SessionDB(context);
-
this.commandTracker = commandTracker;
}
@@ -195,13 +173,7 @@ public synchronized void openConnection() {
}
if (mavlinkConn.getConnectionStatus() == MavLinkConnection.MAVLINK_DISCONNECTED) {
- mavlinkConn.connect();
-
- // Record which connection type is used.
- GAUtils.sendEvent(new HitBuilders.EventBuilder()
- .setCategory(GAUtils.Category.MAVLINK_CONNECTION)
- .setAction("MavLink connect")
- .setLabel(connParams.toString()));
+ mavlinkConn.connect(null);
}
}
@@ -217,17 +189,20 @@ public synchronized void closeConnection() {
if(mavlinkConn.getMavLinkConnectionListenersCount() == 0){
Timber.i("Disconnecting...");
mavlinkConn.disconnect();
- GAUtils.sendEvent(new HitBuilders.EventBuilder()
- .setCategory(GAUtils.Category.MAVLINK_CONNECTION)
- .setAction("MavLink disconnect")
- .setLabel(connParams.toString()));
}
- stopLoggingThread(System.currentTimeMillis());
-
listener.onConnectionStatus(new LinkConnectionStatus(LinkConnectionStatus.DISCONNECTED, null));
}
+ @Override
+ public Bundle getConnectionExtras() {
+ if (mavlinkConn == null) {
+ return null;
+ }
+
+ return mavlinkConn.getConnectionExtras();
+ }
+
@Override
public synchronized void sendMessage(MAVLinkMessage message, ICommandListener listener) {
sendMavMessage(message, DEFAULT_SYS_ID, DEFAULT_COMP_ID, listener);
@@ -265,28 +240,17 @@ private boolean isConnecting(){
return getConnectionStatus() == MavLinkConnection.MAVLINK_CONNECTING;
}
- private File getTLogDir(String appId) {
- return DirectoryPath.getTLogPath(this.context, appId);
- }
-
- private File getTempTLogFile(String appId, long connectionTimestamp) {
- return new File(getTLogDir(appId), getTLogFilename(connectionTimestamp));
- }
-
- private String getTLogFilename(long connectionTimestamp) {
- return TLOG_PREFIX + "_" + MavLinkConnectionTypes.getConnectionTypeLabel(this.connParams.getConnectionType()) +
- "_" + FileUtils.getTimeStamp(connectionTimestamp) + FileUtils.TLOG_FILENAME_EXT;
- }
-
/**
* Register a log listener.
*
* @param appId Tag for the listener.
*/
- public synchronized void addLoggingFile(String appId){
- if(isConnecting() || isConnected()) {
- final File logFile = getTempTLogFile(appId, System.currentTimeMillis());
- mavlinkConn.addLoggingPath(appId, logFile.getAbsolutePath());
+ public synchronized void registerForTLogLogging(String appId, Uri tlogLoggingUri){
+ if(tlogLoggingUri == null)
+ return;
+
+ if (isConnecting() || isConnected()) {
+ mavlinkConn.addLoggingPath(appId, tlogLoggingUri);
}
}
@@ -295,21 +259,10 @@ public synchronized void addLoggingFile(String appId){
*
* @param appId Tag for the listener.
*/
- public synchronized void removeLoggingFile(String appId){
+ public synchronized void unregisterForTLogLogging(String appId){
if(isConnecting() || isConnected()){
mavlinkConn.removeLoggingPath(appId);
}
}
- private void startLoggingThread(long startTime) {
- //log into the database the connection time.
- final String connectionType = MavLinkConnectionTypes.getConnectionTypeLabel(connParams.getConnectionType());
- this.sessionDB.startSession(new Date(startTime), connectionType);
- }
-
- private void stopLoggingThread(long stopTime) {
- //log into the database the disconnection time.
- final String connectionType = MavLinkConnectionTypes.getConnectionTypeLabel(connParams.getConnectionType());
- this.sessionDB.endSession(new Date(stopTime), connectionType, new Date());
- }
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCalibration.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCalibration.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCalibration.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCalibration.java
index 7d863bcad2..a75893ddb8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCalibration.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCalibration.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.MAVLink;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_command_ack;
import com.MAVLink.common.msg_command_long;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_CMD_ACK;
-import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import com.o3dr.services.android.lib.model.ICommandListener;
public class MavLinkCalibration {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCommands.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCommands.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCommands.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCommands.java
index 4c17097660..d05ca227ef 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkCommands.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkCommands.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.MAVLink;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_command_long;
import com.MAVLink.common.msg_manual_control;
@@ -11,8 +11,8 @@
import com.MAVLink.enums.MAV_GOTO;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
public class MavLinkCommands {
@@ -38,7 +38,7 @@ public static void setGuidedMode(MavLinkDrone drone, double latitude, double lon
msg_mission_item msg = new msg_mission_item();
msg.seq = 0;
msg.current = 2; // TODO use guided mode enum
- msg.frame = MAV_FRAME.MAV_FRAME_GLOBAL;
+ msg.frame = MAV_FRAME.MAV_FRAME_GLOBAL_RELATIVE_ALT;
msg.command = MAV_CMD.MAV_CMD_NAV_WAYPOINT; //
msg.param1 = 0; // TODO use correct parameter
msg.param2 = 0; // TODO use correct parameter
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkMsgHandler.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkMsgHandler.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkMsgHandler.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkMsgHandler.java
index 899fcd0ac8..ee18e77ff8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkMsgHandler.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkMsgHandler.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.MAVLink;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.common.msg_heartbeat;
import com.MAVLink.enums.MAV_AUTOPILOT;
import com.MAVLink.enums.MAV_TYPE;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
/**
* Parse the received mavlink messages, and update the drone state appropriately.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkParameters.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkParameters.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkParameters.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkParameters.java
index 49be088377..48bc7aa7c9 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkParameters.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkParameters.java
@@ -1,10 +1,10 @@
-package org.droidplanner.services.android.core.MAVLink;
-
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_param_request_list;
import com.MAVLink.common.msg_param_request_read;
import com.MAVLink.common.msg_param_set;
+
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.drone.property.Parameter;
public class MavLinkParameters {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkRC.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkRC.java
similarity index 82%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkRC.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkRC.java
index 95353ba0d1..32b67b21b8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkRC.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkRC.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.core.MAVLink;
-
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_rc_channels_override;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
public class MavLinkRC {
public static void sendRcOverrideMsg(MavLinkDrone drone, int[] rcOutputs) {
msg_rc_channels_override msg = new msg_rc_channels_override();
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkStreamRates.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkStreamRates.java
similarity index 91%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkStreamRates.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkStreamRates.java
index 664e0ef525..be88535b79 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkStreamRates.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkStreamRates.java
@@ -1,10 +1,10 @@
-package org.droidplanner.services.android.core.MAVLink;
-
-import org.droidplanner.services.android.communication.model.DataLink.DataLinkProvider;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_request_data_stream;
import com.MAVLink.enums.MAV_DATA_STREAM;
+import org.droidplanner.services.android.impl.communication.model.DataLink.DataLinkProvider;
+
public class MavLinkStreamRates {
public static void setupStreamRates(DataLinkProvider MAVClient, byte sysid, byte compid,
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkWaypoint.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkWaypoint.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkWaypoint.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkWaypoint.java
index bba32dc2f0..a7d8fb49d3 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/MavLinkWaypoint.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/MavLinkWaypoint.java
@@ -1,6 +1,4 @@
-package org.droidplanner.services.android.core.MAVLink;
-
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.MAVLink;
import com.MAVLink.common.msg_mission_ack;
import com.MAVLink.common.msg_mission_count;
@@ -9,6 +7,8 @@
import com.MAVLink.common.msg_mission_set_current;
import com.MAVLink.enums.MAV_MISSION_RESULT;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
public class MavLinkWaypoint {
public static void sendAck(MavLinkDrone drone) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/WaypointManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/WaypointManager.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/WaypointManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/WaypointManager.java
index a007ce2caa..92b2520f70 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/WaypointManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/WaypointManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.MAVLink;
+package org.droidplanner.services.android.impl.core.MAVLink;
import android.os.Handler;
@@ -10,9 +10,9 @@
import com.MAVLink.common.msg_mission_item_reached;
import com.MAVLink.common.msg_mission_request;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnWaypointManagerListener;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnWaypointManagerListener;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import java.util.ArrayList;
import java.util.List;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/command/doCmd/MavLinkDoCmds.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/command/doCmd/MavLinkDoCmds.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/command/doCmd/MavLinkDoCmds.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/command/doCmd/MavLinkDoCmds.java
index ed00aba64b..b1d41d87f8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/command/doCmd/MavLinkDoCmds.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/command/doCmd/MavLinkDoCmds.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.MAVLink.command.doCmd;
+package org.droidplanner.services.android.impl.core.MAVLink.command.doCmd;
import com.MAVLink.ardupilotmega.msg_digicam_control;
import com.MAVLink.ardupilotmega.msg_mount_control;
@@ -6,11 +6,11 @@
import com.MAVLink.common.msg_mission_set_current;
import com.MAVLink.enums.GRIPPER_ACTIONS;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
public class MavLinkDoCmds {
public static void setVehicleHome(MavLinkDrone drone, LatLongAlt location, ICommandListener listener){
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnection.java
similarity index 88%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnection.java
index 857242c1e3..c51f2143d8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnection.java
@@ -1,16 +1,18 @@
-package org.droidplanner.services.android.core.MAVLink.connection;
+package org.droidplanner.services.android.impl.core.MAVLink.connection;
+import android.content.Context;
+import android.net.Uri;
import android.os.Bundle;
import android.support.v4.util.Pair;
import com.MAVLink.MAVLinkPacket;
import com.MAVLink.Parser;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
+import com.o3dr.services.android.lib.util.UriUtils;
-import org.droidplanner.services.android.core.model.Logger;
+import org.droidplanner.services.android.impl.core.model.Logger;
import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.net.BindException;
import java.nio.ByteBuffer;
@@ -20,6 +22,7 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Base for mavlink connection implementations.
@@ -40,6 +43,11 @@ public abstract class MavLinkConnection {
*/
private static final int READ_BUFFER_SIZE = 4096;
+ /**
+ * @see {@link android.net.Network}
+ */
+ public static final String EXTRA_NETWORK = "extra_network";
+
/**
* Set of listeners subscribed to this mavlink connection. We're using a
* ConcurrentSkipListSet because the object will be accessed from multiple
@@ -50,7 +58,7 @@ public abstract class MavLinkConnection {
/**
* Stores the list of log files to be written to.
*/
- private final ConcurrentHashMap> loggingOutStreams = new
+ private final ConcurrentHashMap> loggingOutStreams = new
ConcurrentHashMap<>();
/**
@@ -67,6 +75,7 @@ public abstract class MavLinkConnection {
private final AtomicInteger mConnectionStatus = new AtomicInteger(MAVLINK_DISCONNECTED);
private final AtomicLong mConnectionTime = new AtomicLong(-1);
+ private final AtomicReference extrasHolder = new AtomicReference<>();
/**
* Start the connection process.
@@ -78,7 +87,7 @@ public void run() {
loadPreferences();
// Open the connection
try {
- openConnection();
+ openConnection(extrasHolder.get());
} catch (IOException e) {
// Ignore errors while shutting down
if (mConnectionStatus.get() != MAVLINK_DISCONNECTED) {
@@ -216,21 +225,21 @@ public void run() {
logBuffer.clear();
logBuffer.putLong(System.currentTimeMillis() * 1000);
- for (Map.Entry> entry : loggingOutStreams
+ for (Map.Entry> entry : loggingOutStreams
.entrySet()) {
- final Pair logInfo = entry.getValue();
- final String loggingFilePath = logInfo.first;
+ final Pair logInfo = entry.getValue();
+ final Uri loggingFileUri = logInfo.first;
try {
BufferedOutputStream logWriter = logInfo.second;
if (logWriter == null) {
- logWriter = new BufferedOutputStream(new FileOutputStream(loggingFilePath));
- loggingOutStreams.put(entry.getKey(), Pair.create(loggingFilePath, logWriter));
+ logWriter = new BufferedOutputStream(UriUtils.getOutputStream(context, loggingFileUri));
+ loggingOutStreams.put(entry.getKey(), Pair.create(loggingFileUri, logWriter));
}
logWriter.write(logBuffer.array());
logWriter.write(packetData);
} catch (IOException e) {
- mLogger.logErr(TAG, "IO Exception while writing to " + loggingFilePath, e);
+ mLogger.logErr(TAG, "IO Exception while writing to " + loggingFileUri, e);
}
}
}
@@ -240,14 +249,14 @@ public void run() {
mLogger.logVerbose(TAG, errorMessage);
}
} finally {
- for (Pair entry : loggingOutStreams.values()) {
- final String loggingFilePath = entry.first;
+ for (Pair entry : loggingOutStreams.values()) {
+ final Uri loggingFileUri = entry.first;
try {
if (entry.second != null) {
entry.second.close();
}
} catch (IOException e) {
- mLogger.logErr(TAG, "IO Exception while closing " + loggingFilePath, e);
+ mLogger.logErr(TAG, "IO Exception while closing " + loggingFileUri, e);
}
}
@@ -257,16 +266,18 @@ public void run() {
};
protected final Logger mLogger = initLogger();
+ protected final Context context;
private Thread mConnectThread;
private Thread mTaskThread;
- /**
- * Establish a mavlink connection. If the connection is successful, it will
- * be reported through the MavLinkConnectionListener interface.
- */
- public void connect() {
+ protected MavLinkConnection(Context context){
+ this.context = context;
+ }
+
+ public void connect(Bundle extras) {
if (mConnectionStatus.compareAndSet(MAVLINK_DISCONNECTED, MAVLINK_CONNECTING)) {
+ extrasHolder.set(extras);
mLogger.logInfo(TAG, "Starting connection thread.");
mConnectThread = new Thread(mConnectingTask, "MavLinkConnection-Connecting Thread");
mConnectThread.start();
@@ -274,8 +285,9 @@ public void connect() {
}
}
- protected void onConnectionOpened() {
+ protected void onConnectionOpened(Bundle extras) {
if (mConnectionStatus.compareAndSet(MAVLINK_CONNECTING, MAVLINK_CONNECTED)) {
+ extrasHolder.set(extras);
mLogger.logInfo(TAG, "Starting manager thread.");
mTaskThread = new Thread(mManagerTask, "MavLinkConnection-Manager Thread");
mTaskThread.start();
@@ -303,10 +315,9 @@ public void disconnect() {
}
try {
- final long disconnectTime = System.currentTimeMillis();
-
mConnectionStatus.set(MAVLINK_DISCONNECTED);
mConnectionTime.set(-1);
+ extrasHolder.set(null);
if (mConnectThread != null && mConnectThread.isAlive() && !mConnectThread.isInterrupted()) {
mConnectThread.interrupt();
@@ -349,13 +360,13 @@ private void queueToLog(byte[] packetData) {
}
}
- public void addLoggingPath(String tag, String loggingPath) {
- if (tag == null || tag.length() == 0 || loggingPath == null || loggingPath.length() == 0) {
+ public void addLoggingPath(String tag, Uri loggingUri) {
+ if (tag == null || tag.length() == 0 || loggingUri == null) {
return;
}
if (!loggingOutStreams.contains(tag)) {
- loggingOutStreams.put(tag, Pair.create(loggingPath, null));
+ loggingOutStreams.put(tag, Pair.create(loggingUri, null));
}
}
@@ -364,7 +375,7 @@ public void removeLoggingPath(String tag) {
return;
}
- Pair logInfo = loggingOutStreams.remove(tag);
+ Pair logInfo = loggingOutStreams.remove(tag);
if (logInfo != null) {
BufferedOutputStream outStream = logInfo.second;
if (outStream != null) {
@@ -400,6 +411,10 @@ public int getMavLinkConnectionListenersCount() {
return mListeners.size();
}
+ public Bundle getConnectionExtras() {
+ return extrasHolder.get();
+ }
+
/**
* Used to query the presence of a connection listener.
*
@@ -428,7 +443,7 @@ public void removeAllMavLinkConnectionListeners() {
protected abstract Logger initLogger();
- protected abstract void openConnection() throws IOException;
+ protected abstract void openConnection(Bundle connectionExtras) throws IOException;
protected abstract int readDataBlock(byte[] buffer) throws IOException;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionListener.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionListener.java
similarity index 88%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionListener.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionListener.java
index 75cb55e9d9..81a3c3ed03 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionListener.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionListener.java
@@ -1,6 +1,7 @@
-package org.droidplanner.services.android.core.MAVLink.connection;
+package org.droidplanner.services.android.impl.core.MAVLink.connection;
import com.MAVLink.MAVLinkPacket;
+
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
/**
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionTypes.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionTypes.java
new file mode 100644
index 0000000000..aa192c751d
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/MavLinkConnectionTypes.java
@@ -0,0 +1,31 @@
+package org.droidplanner.services.android.impl.core.MAVLink.connection;
+
+/**
+ * List the supported mavlink connection types.
+ */
+public class MavLinkConnectionTypes {
+
+ /**
+ * Bluetooth mavlink connection.
+ */
+ public static final int MAVLINK_CONNECTION_BLUETOOTH = 3;
+
+ /**
+ * USP mavlink connection.
+ */
+ public static final int MAVLINK_CONNECTION_USB = 0;
+
+ /**
+ * UDP mavlink connection.
+ */
+ public static final int MAVLINK_CONNECTION_UDP = 1;
+
+ /**
+ * TCP mavlink connection.
+ */
+ public static final int MAVLINK_CONNECTION_TCP = 2;
+
+ // Not instantiable
+ private MavLinkConnectionTypes() {
+ }
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/TcpConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/TcpConnection.java
similarity index 75%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/TcpConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/TcpConnection.java
index c450d155a0..17a1ae758f 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/TcpConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/TcpConnection.java
@@ -1,4 +1,9 @@
-package org.droidplanner.services.android.core.MAVLink.connection;
+package org.droidplanner.services.android.impl.core.MAVLink.connection;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -21,10 +26,14 @@ public abstract class TcpConnection extends MavLinkConnection {
private String serverIP;
private int serverPort;
+ protected TcpConnection(Context context) {
+ super(context);
+ }
+
@Override
- public final void openConnection() throws IOException {
- getTCPStream();
- onConnectionOpened();
+ public final void openConnection(Bundle connectionExtras) throws IOException {
+ getTCPStream(connectionExtras);
+ onConnectionOpened(connectionExtras);
}
@Override
@@ -57,9 +66,10 @@ public final void closeConnection() throws IOException {
}
}
- private void getTCPStream() throws IOException {
+ private void getTCPStream(Bundle extras) throws IOException {
InetAddress serverAddr = InetAddress.getByName(serverIP);
socket = new Socket();
+ NetworkUtils.bindSocketToNetwork(extras, socket);
socket.connect(new InetSocketAddress(serverAddr, serverPort), CONNECTION_TIMEOUT);
mavOut = new BufferedOutputStream((socket.getOutputStream()));
mavIn = new BufferedInputStream(socket.getInputStream());
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/UdpConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/UdpConnection.java
similarity index 84%
rename from ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/UdpConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/UdpConnection.java
index 54cc67a39e..f220c1ceda 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/UdpConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/MAVLink/connection/UdpConnection.java
@@ -1,4 +1,9 @@
-package org.droidplanner.services.android.core.MAVLink.connection;
+package org.droidplanner.services.android.impl.core.MAVLink.connection;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
import java.io.IOException;
import java.net.DatagramPacket;
@@ -19,10 +24,15 @@ public abstract class UdpConnection extends MavLinkConnection {
private DatagramPacket sendPacket;
private DatagramPacket receivePacket;
- private void getUdpStream() throws IOException {
+ protected UdpConnection(Context context) {
+ super(context);
+ }
+
+ private void getUdpStream(Bundle extras) throws IOException {
final DatagramSocket socket = new DatagramSocket(serverPort);
socket.setBroadcast(true);
socket.setReuseAddress(true);
+ NetworkUtils.bindSocketToNetwork(extras, socket);
socketRef.set(socket);
}
@@ -35,9 +45,9 @@ public final void closeConnection() throws IOException {
}
@Override
- public final void openConnection() throws IOException {
- getUdpStream();
- onConnectionOpened();
+ public final void openConnection(Bundle connectionExtras) throws IOException {
+ getUdpStream(connectionExtras);
+ onConnectionOpened(connectionExtras);
}
@Override
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneEvents.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneEvents.java
new file mode 100644
index 0000000000..edf9605e6e
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneEvents.java
@@ -0,0 +1,39 @@
+package org.droidplanner.services.android.impl.core.drone;
+
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class DroneEvents extends DroneVariable {
+
+ private final ConcurrentLinkedQueue droneListeners = new ConcurrentLinkedQueue();
+
+ public DroneEvents(MavLinkDrone myDrone) {
+ super(myDrone);
+ }
+
+ public void addDroneListener(OnDroneListener listener) {
+ if (listener != null & !droneListeners.contains(listener))
+ droneListeners.add(listener);
+ }
+
+ public void removeDroneListener(OnDroneListener listener) {
+ if (listener != null && droneListeners.contains(listener))
+ droneListeners.remove(listener);
+ }
+
+ public void removeAllDroneListeners(){
+ droneListeners.clear();
+ }
+
+ public void notifyDroneEvent(DroneEventsType event) {
+ if (event == null || droneListeners.isEmpty())
+ return;
+
+ for (OnDroneListener listener : droneListeners) {
+ listener.onDroneEvent(event, myDrone);
+ }
+ }
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneInterfaces.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneInterfaces.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/DroneInterfaces.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneInterfaces.java
index 32be8546e6..ff3a609fea 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneInterfaces.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneInterfaces.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.drone;
+package org.droidplanner.services.android.impl.core.drone;
import android.os.Bundle;
import com.o3dr.services.android.lib.drone.property.Parameter;
-import org.droidplanner.services.android.core.MAVLink.WaypointManager;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.MAVLink.WaypointManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
public class DroneInterfaces {
@@ -203,7 +203,7 @@ public interface OnDroneListener {
}
public interface AttributeEventListener {
- void onAttributeEvent(String attributeEvent, Bundle eventInfo, boolean checkForSololinkApi);
+ void onAttributeEvent(String attributeEvent, Bundle eventInfo);
}
public interface OnParameterManagerListener {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneManager.java
similarity index 76%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/DroneManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneManager.java
index 7eb4b88c75..9742273308 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone;
+package org.droidplanner.services.android.impl.core.drone;
import android.content.Context;
import android.os.Bundle;
@@ -11,20 +11,19 @@
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
-import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
import com.o3dr.services.android.lib.drone.property.Parameter;
+import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.api.DroneApi;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.ArduSolo;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.SoloComp;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.utils.CommonApiUtils;
-import org.droidplanner.services.android.utils.analytics.GAUtils;
+import org.droidplanner.services.android.impl.api.DroneApi;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.ArduSolo;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.SoloComp;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
import java.util.concurrent.ConcurrentHashMap;
@@ -38,8 +37,6 @@ public class DroneManager implements DataLink.DataLinkListen
public static final String EXTRA_CLIENT_APP_ID = "extra_client_app_id";
- private static final int SOLOLINK_API_MIN_VERSION = 20412;
-
protected final ConcurrentHashMap connectedApps = new ConcurrentHashMap<>();
protected final Context context;
@@ -80,16 +77,16 @@ public void destroy() {
}
- public synchronized void connect(String appId, DroneApi listener) {
+ public synchronized void connect(String appId, DroneApi listener, ConnectionParameter connParams) {
if (listener == null || TextUtils.isEmpty(appId)) {
return;
}
connectedApps.put(appId, listener);
- doConnect(appId, listener);
+ doConnect(appId, listener, connParams);
}
- protected void doConnect(String appId, DroneApi listener) {
+ protected void doConnect(String appId, DroneApi listener, ConnectionParameter connParams) {
}
@@ -108,10 +105,8 @@ protected boolean isCompanionComputerEnabled() {
final int connectionType = connectionParameter.getConnectionType();
return drone instanceof ArduSolo
- ||
- (connectionType == ConnectionType.TYPE_UDP && SoloComp.isAvailable(context) && doAnyListenersSupportSoloLinkApi())
- ||
- connectionType == ConnectionType.TYPE_SOLO;
+ || (connectionType == ConnectionType.TYPE_UDP && SoloComp.isAvailable(context))
+ || connectionType == ConnectionType.TYPE_SOLO;
}
@@ -159,11 +154,7 @@ public void onConnectionStatus(LinkConnectionStatus connectionStatus) {
case LinkConnectionStatus.DISCONNECTED:
notifyDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED);
break;
- case LinkConnectionStatus.CONNECTED:
- // Start a new ga analytics session. The new session will be tagged
- // with the mavlink connection mechanism, as well as whether the user has an active droneshare account.
- GAUtils.startNewSession(null);
- break;
+
case LinkConnectionStatus.CONNECTING:
notifyDroneEvent(DroneInterfaces.DroneEventsType.CONNECTING);
break;
@@ -230,51 +221,13 @@ public boolean executeAsyncAction(DroneApi.ClientInfo clientInfo, Action action,
}
protected void notifyDroneAttributeEvent(String attributeEvent, Bundle eventInfo) {
- notifyDroneAttributeEvent(attributeEvent, eventInfo, false);
- }
-
- /**
- * Temporary delegate to prevent sending of newly defined payload to older version of the api
- * #FIXME: remove when old version of the api is phased out.
- *
- * @param attributeEvent
- * @param eventInfo
- * @param checkForSoloLinkApi
- */
- private void notifyDroneAttributeEvent(String attributeEvent, Bundle eventInfo, boolean checkForSoloLinkApi) {
if (TextUtils.isEmpty(attributeEvent) || connectedApps.isEmpty()) {
return;
}
for (DroneApi listener : connectedApps.values()) {
- if (checkForSoloLinkApi && !supportSoloLinkApi(listener)) {
- continue;
- }
- listener.onAttributeEvent(attributeEvent, eventInfo, checkForSoloLinkApi);
- }
- }
-
- private boolean supportSoloLinkApi(DroneApi listener) {
- return listener != null && listener.getClientInfo().apiVersionCode >= SOLOLINK_API_MIN_VERSION;
- }
-
- /**
- * FIXME: remove when android solo v2 is released.
- *
- * @return
- */
- private boolean doAnyListenersSupportSoloLinkApi() {
- if (connectedApps.isEmpty()) {
- return false;
- }
-
- for (DroneApi listener : connectedApps.values()) {
- if (supportSoloLinkApi(listener)) {
- return true;
- }
+ listener.onAttributeEvent(attributeEvent, eventInfo);
}
-
- return false;
}
@Override
@@ -344,7 +297,7 @@ public void onMessageLogged(int logLevel, String message) {
}
@Override
- public void onAttributeEvent(String attributeEvent, Bundle eventInfo, boolean checkForSololinkApi) {
- notifyDroneAttributeEvent(attributeEvent, eventInfo, checkForSololinkApi);
+ public void onAttributeEvent(String attributeEvent, Bundle eventInfo) {
+ notifyDroneAttributeEvent(attributeEvent, eventInfo);
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneVariable.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneVariable.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/DroneVariable.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneVariable.java
index 4f107d983b..faf75dcf09 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneVariable.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/DroneVariable.java
@@ -1,12 +1,11 @@
-package org.droidplanner.services.android.core.drone;
+package org.droidplanner.services.android.impl.core.drone;
import android.os.Handler;
import android.os.RemoteException;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
import timber.log.Timber;
public class DroneVariable {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/LogMessageListener.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/LogMessageListener.java
similarity index 72%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/LogMessageListener.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/LogMessageListener.java
index f3ce87eb05..09e2fa69c1 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/LogMessageListener.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/LogMessageListener.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone;
+package org.droidplanner.services.android.impl.core.drone;
/**
* Created by Fredia Huya-Kouadio on 3/23/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/Drone.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/Drone.java
similarity index 86%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/Drone.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/Drone.java
index 75db51176e..305903f9fe 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/Drone.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/Drone.java
@@ -1,11 +1,10 @@
-package org.droidplanner.services.android.core.drone.autopilot;
+package org.droidplanner.services.android.impl.core.drone.autopilot;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-
/**
* Created by Fredia Huya-Kouadio on 7/27/15.
*/
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/MavLinkDrone.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/MavLinkDrone.java
new file mode 100644
index 0000000000..4e7e820c67
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/MavLinkDrone.java
@@ -0,0 +1,62 @@
+package org.droidplanner.services.android.impl.core.drone.autopilot;
+
+import com.MAVLink.Messages.MAVLinkMessage;
+
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.WaypointManager;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterManager;
+import org.droidplanner.services.android.impl.core.drone.variables.Camera;
+import org.droidplanner.services.android.impl.core.drone.variables.GuidedPoint;
+import org.droidplanner.services.android.impl.core.drone.variables.MissionStats;
+import org.droidplanner.services.android.impl.core.drone.variables.State;
+import org.droidplanner.services.android.impl.core.drone.variables.StreamRates;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.AccelCalibration;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+
+public interface MavLinkDrone extends Drone {
+
+ String PACKAGE_NAME = "org.droidplanner.services.android.core.drone.autopilot";
+
+ String ACTION_REQUEST_HOME_UPDATE = PACKAGE_NAME + ".action.REQUEST_HOME_UPDATE";
+
+ boolean isConnectionAlive();
+
+ int getMavlinkVersion();
+
+ void onMavLinkMessageReceived(MAVLinkMessage message);
+
+ public byte getSysid();
+
+ public byte getCompid();
+
+ public State getState();
+
+ public ParameterManager getParameterManager();
+
+ public int getType();
+
+ public FirmwareType getFirmwareType();
+
+ public DataLink.DataLinkProvider getMavClient();
+
+ public WaypointManager getWaypointManager();
+
+ public MissionImpl getMission();
+
+ public StreamRates getStreamRates();
+
+ public MissionStats getMissionStats();
+
+ public GuidedPoint getGuidedPoint();
+
+ public AccelCalibration getCalibrationSetup();
+
+ public MagnetometerCalibrationImpl getMagnetometerCalibration();
+
+ public String getFirmwareVersion();
+
+ public Camera getCamera();
+
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/APMConstants.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/APMConstants.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/APMConstants.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/APMConstants.java
index f97fae07cd..7c1bdeda2d 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/APMConstants.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/APMConstants.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm;
/**
* Set of APM autopilots related constants.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduCopter.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduCopter.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduCopter.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduCopter.java
index 08d05174d6..a6f2fd5483 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduCopter.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduCopter.java
@@ -1,38 +1,40 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
-import com.github.zafarkhaja.semver.Version;
import com.MAVLink.Messages.MAVLinkMessage;
+import com.github.zafarkhaja.semver.Version;
import com.o3dr.android.client.apis.CapabilityApi;
import com.o3dr.services.android.lib.drone.action.ControlActions;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.drone.property.Parameter;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneManager;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.profiles.ParameterManager;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
-import org.droidplanner.services.android.core.drone.variables.State;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneManager;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterManager;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.variables.State;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* Created by Fredia Huya-Kouadio on 7/27/15.
*/
public class ArduCopter extends ArduPilot {
- private static final Version BRAKE_FEATURE_FIRMWARE_VERSION = Version.forIntegers(3, 3, 0);
+ private static final Version ARDU_COPTER_V3_3 = Version.forIntegers(3,3,0);
+ private static final Version ARDU_COPTER_V3_4 = Version.forIntegers(3,4,0);
+
+ private static final Version BRAKE_FEATURE_FIRMWARE_VERSION = ARDU_COPTER_V3_3;
+ private static final Version COMPASS_CALIBRATION_MIN_VERSION = ARDU_COPTER_V3_4;
private final ConcurrentHashMap manualControlStateListeners = new ConcurrentHashMap<>();
@@ -146,6 +148,9 @@ protected boolean isFeatureSupported(String featureId){
case CapabilityApi.FeatureIds.KILL_SWITCH:
return CommonApiUtils.isKillSwitchSupported(this);
+ case CapabilityApi.FeatureIds.COMPASS_CALIBRATION:
+ return getFirmwareVersionNumber().greaterThanOrEqualTo(COMPASS_CALIBRATION_MIN_VERSION);
+
default:
return super.isFeatureSupported(featureId);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilot.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilot.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilot.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilot.java
index 88b36c1a54..9e9d5617c8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduPilot.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduPilot.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm;
import android.content.Context;
import android.os.Bundle;
@@ -23,6 +23,25 @@
import com.MAVLink.enums.MAV_MOUNT_MODE;
import com.MAVLink.enums.MAV_SYS_STATUS_SENSOR;
import com.github.zafarkhaja.semver.Version;
+
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkParameters;
+import org.droidplanner.services.android.impl.core.MAVLink.WaypointManager;
+import org.droidplanner.services.android.impl.core.MAVLink.command.doCmd.MavLinkDoCmds;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.variables.APMHeartBeat;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.variables.Camera;
+import org.droidplanner.services.android.impl.core.drone.variables.GuidedPoint;
+import org.droidplanner.services.android.impl.core.drone.variables.HeartBeat;
+import org.droidplanner.services.android.impl.core.drone.variables.Magnetometer;
+import org.droidplanner.services.android.impl.core.drone.variables.RC;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.AccelCalibration;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.action.ControlActions;
@@ -42,26 +61,7 @@
import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.MavLinkParameters;
-import org.droidplanner.services.android.core.MAVLink.WaypointManager;
-import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.autopilot.apm.variables.APMHeartBeat;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
-import org.droidplanner.services.android.core.drone.variables.Camera;
-import org.droidplanner.services.android.core.drone.variables.GuidedPoint;
-import org.droidplanner.services.android.core.drone.variables.HeartBeat;
-import org.droidplanner.services.android.core.drone.variables.Magnetometer;
-import org.droidplanner.services.android.core.drone.variables.RC;
-import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -78,8 +78,8 @@ public abstract class ArduPilot extends GenericMavLinkDrone {
public static final String FIRMWARE_VERSION_NUMBER_REGEX = "\\d+(\\.\\d{1,2})?";
- private final org.droidplanner.services.android.core.drone.variables.RC rc;
- private final Mission mission;
+ private final org.droidplanner.services.android.impl.core.drone.variables.RC rc;
+ private final MissionImpl missionImpl;
private final GuidedPoint guidedPoint;
private final AccelCalibration accelCalibrationSetup;
private final WaypointManager waypointManager;
@@ -99,7 +99,7 @@ public ArduPilot(String droneId, Context context, DataLink.DataLinkProvider mavClient, Handler handler, AutopilotWarningParser warningParser, LogMessageListener logListener) {
super(droneId, context, mavClient, handler, warningParser, logListener);
}
@@ -61,5 +67,16 @@ protected void processGlobalPositionInt(msg_global_position_int gpi){
setAltitudeGroundAndAirSpeeds(relativeAlt, groundSpeed, groundSpeed, climbRate);
}
+ @Override
+ protected boolean isFeatureSupported(String featureId){
+ switch(featureId){
+ case CapabilityApi.FeatureIds.COMPASS_CALIBRATION:
+ return getFirmwareVersionNumber().greaterThanOrEqualTo(COMPASS_CALIBRATION_MIN_VERSION);
+
+ default:
+ return super.isFeatureSupported(featureId);
+ }
+ }
+
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduRover.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduRover.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduRover.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduRover.java
index e4c2dab31b..c5dffa322a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/ArduRover.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/ArduRover.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm;
import android.content.Context;
import android.os.Handler;
@@ -6,10 +6,10 @@
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.enums.MAV_TYPE;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
/**
* Created by Fredia Huya-Kouadio on 7/27/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/AbstractLinkManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/AbstractLinkManager.java
similarity index 88%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/AbstractLinkManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/AbstractLinkManager.java
index 824e53bc25..bd72f973d5 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/AbstractLinkManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/AbstractLinkManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.solo;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo;
import android.content.Context;
import android.os.Handler;
@@ -9,7 +9,8 @@
import com.o3dr.android.client.utils.connection.IpConnectionListener;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.utils.connection.SshConnection;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.utils.connection.SshConnection;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
@@ -43,7 +44,7 @@ public interface LinkListener {
@Override
public void run() {
handler.removeCallbacks(reconnectTask);
- linkConn.connect();
+ linkConn.connect(linkProvider.getConnectionExtras());
}
};
@@ -70,16 +71,22 @@ public void run() {
protected final Context context;
protected final AbstractIpConnection linkConn;
+ protected final DataLink.DataLinkProvider linkProvider;
private T linkListener;
- public AbstractLinkManager(Context context, AbstractIpConnection ipConn, Handler handler, ExecutorService asyncExecutor) {
+ public AbstractLinkManager(Context context,
+ AbstractIpConnection ipConn,
+ Handler handler,
+ ExecutorService asyncExecutor,
+ DataLink.DataLinkProvider linkProvider) {
this.context = context;
this.linkConn = ipConn;
this.linkConn.setIpConnectionListener(this);
this.handler = handler;
this.asyncExecutor = asyncExecutor;
+ this.linkProvider = linkProvider;
}
protected void postAsyncTask(Runnable task){
@@ -143,7 +150,7 @@ public void start(T listener) {
handler.removeCallbacks(reconnectTask);
isStarted.set(true);
- this.linkConn.connect();
+ this.linkConn.connect(linkProvider.getConnectionExtras());
this.linkListener = listener;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/ArduSolo.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/ArduSolo.java
similarity index 88%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/ArduSolo.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/ArduSolo.java
index 80a8c42200..443d427479 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/ArduSolo.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/ArduSolo.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.solo;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo;
import android.content.Context;
import android.os.Bundle;
@@ -11,7 +11,6 @@
import com.MAVLink.common.msg_statustext;
import com.MAVLink.enums.MAV_TYPE;
import com.o3dr.android.client.apis.CapabilityApi;
-import com.o3dr.android.client.utils.TxPowerComplianceCountries;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
@@ -29,20 +28,19 @@
import com.o3dr.services.android.lib.drone.companion.solo.tlv.TLVPacket;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
import com.o3dr.services.android.lib.drone.property.State;
-import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduCopter;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
-import org.droidplanner.services.android.core.drone.variables.HeartBeat;
-import org.droidplanner.services.android.core.drone.variables.StreamRates;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.utils.SoloApiUtils;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduCopter;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.variables.HeartBeat;
+import org.droidplanner.services.android.impl.core.drone.variables.StreamRates;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
+import org.droidplanner.services.android.impl.utils.SoloApiUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -62,7 +60,7 @@ public class ArduSolo extends ArduCopter {
private final Runnable disconnectSoloCompTask = new Runnable() {
@Override
public void run() {
- if (soloComp != null && soloComp.isConnected()) {
+ if (soloComp.isConnected()) {
soloComp.stop();
}
@@ -77,7 +75,7 @@ public void run() {
public ArduSolo(String droneId, Context context, DataLink.DataLinkProvider mavClient, Handler handler,
AutopilotWarningParser warningParser, LogMessageListener logListener) {
super(droneId, context, mavClient, handler, warningParser, logListener);
- this.soloComp = new SoloComp(context, handler);
+ this.soloComp = new SoloComp(context, handler, mavClient);
this.soloComp.setListener(new SoloComp.SoloCompListener() {
@Override
public void onConnected() {
@@ -93,7 +91,6 @@ public void onDisconnected() {
@Override
public void onTlvPacketReceived(TLVPacket packet) {
- //TODO: filter the message that are broadcast.
switch (packet.getMessageType()) {
case TLVMessageTypes.TYPE_ARTOO_INPUT_REPORT_MESSAGE:
//Drop this message as only the battery info is enabled, and that info is already
@@ -117,33 +114,33 @@ public void onTlvPacketReceived(TLVPacket packet) {
final Bundle messageInfo = new Bundle();
messageInfo.putParcelable(SoloEventExtras.EXTRA_SOLO_MESSAGE_DATA, packet);
- notifyAttributeListener(SoloEvents.SOLO_MESSAGE_RECEIVED, messageInfo, true);
+ notifyAttributeListener(SoloEvents.SOLO_MESSAGE_RECEIVED, messageInfo);
break;
}
}
@Override
public void onPresetButtonLoaded(int buttonType, SoloButtonSetting buttonSettings) {
- notifyAttributeListener(SoloEvents.SOLO_BUTTON_SETTINGS_UPDATED, null, true);
+ notifyAttributeListener(SoloEvents.SOLO_BUTTON_SETTINGS_UPDATED, null);
}
@Override
public void onWifiInfoUpdated(String wifiName, String wifiPassword) {
- notifyAttributeListener(SoloEvents.SOLO_WIFI_SETTINGS_UPDATED, null, true);
+ notifyAttributeListener(SoloEvents.SOLO_WIFI_SETTINGS_UPDATED, null);
}
@Override
public void onButtonPacketReceived(ButtonPacket packet) {
final Bundle eventInfo = new Bundle();
eventInfo.putParcelable(SoloEventExtras.EXTRA_SOLO_BUTTON_EVENT, packet);
- notifyAttributeListener(SoloEvents.SOLO_BUTTON_EVENT_RECEIVED, eventInfo, true);
+ notifyAttributeListener(SoloEvents.SOLO_BUTTON_EVENT_RECEIVED, eventInfo);
}
@Override
public void onTxPowerComplianceCountryUpdated(String compliantCountry) {
final Bundle eventInfo = new Bundle(1);
eventInfo.putString(SoloEventExtras.EXTRA_SOLO_TX_POWER_COMPLIANT_COUNTRY, compliantCountry);
- notifyAttributeListener(SoloEvents.SOLO_TX_POWER_COMPLIANCE_COUNTRY_UPDATED, eventInfo, true);
+ notifyAttributeListener(SoloEvents.SOLO_TX_POWER_COMPLIANCE_COUNTRY_UPDATED, eventInfo);
}
@Override
@@ -155,12 +152,12 @@ public void onVersionsUpdated() {
eventInfo.putString(SoloEventExtras.EXTRA_SOLO_CONTROLLER_VERSION, soloComp.getControllerVersion());
eventInfo.putString(SoloEventExtras.EXTRA_SOLO_CONTROLLER_FIRMWARE_VERSION, soloComp.getControllerFirmwareVersion());
- notifyAttributeListener(SoloEvents.SOLO_VERSIONS_UPDATED, eventInfo, true);
+ notifyAttributeListener(SoloEvents.SOLO_VERSIONS_UPDATED, eventInfo);
}
@Override
public void onControllerEvent(String event, Bundle eventInfo) {
- notifyAttributeListener(event, eventInfo, true);
+ notifyAttributeListener(event, eventInfo);
}
});
}
@@ -335,14 +332,6 @@ public boolean executeAsyncAction(Action action, final ICommandListener listener
SoloApiUtils.updateSoloLinkControllerMode(this, mode, listener);
return true;
- //TODO remove this when deprecated methods are deleted in 3.0
- case SoloConfigActions.ACTION_UPDATE_EU_TX_POWER_COMPLIANCE:
- final boolean isCompliant = data.getBoolean(SoloConfigActions.EXTRA_EU_TX_POWER_COMPLIANT);
- String compliantCountryCode = isCompliant ? TxPowerComplianceCountries.getDefaultEUCountry().name() :
- TxPowerComplianceCountries.getDefaultCountry().name();
- SoloApiUtils.updateSoloLinkTxPowerComplianceCountry(this, compliantCountryCode, listener);
- return true;
-
case SoloConfigActions.ACTION_UPDATE_TX_POWER_COMPLIANCE_COUNTRY:
final String compliantCountry = data.getString(SoloConfigActions.EXTRA_TX_POWER_COMPLIANT_COUNTRY_CODE);
SoloApiUtils.updateSoloLinkTxPowerComplianceCountry(this, compliantCountry, listener);
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/SoloComp.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/SoloComp.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/SoloComp.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/SoloComp.java
index 4017d32a62..124fb0d9ba 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/SoloComp.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/SoloComp.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.solo;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo;
import android.content.Context;
import android.os.Bundle;
@@ -8,6 +8,7 @@
import android.util.Pair;
import android.util.SparseArray;
+import com.o3dr.android.client.BuildConfig;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.drone.companion.solo.SoloEventExtras;
@@ -25,12 +26,12 @@
import com.o3dr.services.android.lib.drone.companion.solo.tlv.TLVPacket;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.BuildConfig;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.controller.ControllerLinkListener;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.controller.ControllerLinkManager;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.sololink.SoloLinkListener;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.sololink.SoloLinkManager;
-import org.droidplanner.services.android.utils.NetworkUtils;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.controller.ControllerLinkListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.controller.ControllerLinkManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.sololink.SoloLinkListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.sololink.SoloLinkManager;
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -85,14 +86,14 @@ public interface SoloCompListener {
*
* @param context Application context
*/
- public SoloComp(Context context, Handler handler) {
+ public SoloComp(Context context, Handler handler, DataLink.DataLinkProvider mavClient) {
this.context = context;
this.handler = handler;
asyncExecutor = Executors.newCachedThreadPool();
- this.controllerLinkManager = new ControllerLinkManager(context, handler, asyncExecutor);
- this.soloLinkMgr = new SoloLinkManager(context, handler, asyncExecutor);
+ this.controllerLinkManager = new ControllerLinkManager(context, handler, asyncExecutor, mavClient);
+ this.soloLinkMgr = new SoloLinkManager(context, handler, asyncExecutor, mavClient);
}
public SoloGoproState getGoproState() {
@@ -115,7 +116,6 @@ public void setListener(SoloCompListener listener) {
}
public static boolean isAvailable(Context context) {
- //TODO: complement the logic.
return NetworkUtils.isOnSololinkNetwork(context);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java
index 5a22767982..d723262088 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkListener.java
@@ -1,11 +1,10 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.solo.controller;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.controller;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.AbstractLinkManager;
import com.o3dr.services.android.lib.drone.companion.solo.button.ButtonPacket;
import com.o3dr.services.android.lib.drone.companion.solo.controller.SoloControllerUnits;
import com.o3dr.services.android.lib.drone.companion.solo.tlv.TLVPacket;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.AbstractLinkManager;
-
/**
* Created by Fredia Huya-Kouadio on 7/10/15.
*/
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java
index d4c9a7c0c1..019be3d427 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/solo/controller/ControllerLinkManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.solo.controller;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.controller;
import android.content.Context;
import android.os.Handler;
@@ -17,10 +17,11 @@
import com.o3dr.services.android.lib.drone.companion.solo.tlv.TLVPacket;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.AbstractLinkManager;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.SoloComp;
-import org.droidplanner.services.android.utils.NetworkUtils;
-import org.droidplanner.services.android.utils.connection.SshConnection;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.AbstractLinkManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.SoloComp;
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
+import org.droidplanner.services.android.impl.utils.connection.SshConnection;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -74,7 +75,7 @@ public class ControllerLinkManager extends AbstractLinkManager {
private final UdpConnection followDataConn;
- private static final SshConnection sshLink = new SshConnection(getSoloLinkIp(), SoloComp.SSH_USERNAME, SoloComp.SSH_PASSWORD);
+ private final SshConnection sshLink;
private final SoloButtonSettingGetter presetButtonAGetter = new SoloButtonSettingGetter(ButtonTypes.BUTTON_A,
ButtonTypes.BUTTON_EVENT_PRESS);
@@ -108,9 +108,13 @@ public void run() {
private SoloLinkListener linkListener;
- public SoloLinkManager(Context context, Handler handler, ExecutorService asyncExecutor) {
- super(context, new TcpConnection(handler, getSoloLinkIp(), SOLO_LINK_TCP_PORT), handler, asyncExecutor);
+ public SoloLinkManager(Context context, Handler handler, ExecutorService asyncExecutor,
+ DataLink.DataLinkProvider mavClient) {
+ super(context, new TcpConnection(handler, getSoloLinkIp(), SOLO_LINK_TCP_PORT), handler,
+ asyncExecutor,
+ mavClient);
+ sshLink = new SshConnection(getSoloLinkIp(), SoloComp.SSH_USERNAME, SoloComp.SSH_PASSWORD, mavClient);
UdpConnection dataConn = null;
try {
dataConn = new UdpConnection(handler, getSoloLinkIp(), SHOT_FOLLOW_UDP_PORT, 14557);
@@ -322,7 +326,7 @@ public void disableFollowDataConnection() {
public void enableFollowDataConnection() {
if (followDataConn != null) {
- followDataConn.connect();
+ followDataConn.connect(linkProvider.getConnectionExtras());
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/variables/APMHeartBeat.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/variables/APMHeartBeat.java
similarity index 75%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/variables/APMHeartBeat.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/variables/APMHeartBeat.java
index f927212980..94c591ec15 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/apm/variables/APMHeartBeat.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/apm/variables/APMHeartBeat.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.drone.autopilot.apm.variables;
+package org.droidplanner.services.android.impl.core.drone.autopilot.apm.variables;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduPilot;
-import org.droidplanner.services.android.core.drone.variables.HeartBeat;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduPilot;
+import org.droidplanner.services.android.impl.core.drone.variables.HeartBeat;
/**
* Created by Fredia Huya-Kouadio on 10/24/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/generic/GenericMavLinkDrone.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/generic/GenericMavLinkDrone.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/generic/GenericMavLinkDrone.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/generic/GenericMavLinkDrone.java
index 4295cd0395..1804cb2960 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/generic/GenericMavLinkDrone.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/generic/GenericMavLinkDrone.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.autopilot.generic;
+package org.droidplanner.services.android.impl.core.drone.autopilot.generic;
import android.content.Context;
import android.os.Bundle;
@@ -49,32 +49,31 @@
import com.o3dr.services.android.lib.model.action.Action;
import com.o3dr.services.android.lib.util.MathUtils;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.MAVLink.MavLinkWaypoint;
-import org.droidplanner.services.android.core.MAVLink.WaypointManager;
-import org.droidplanner.services.android.core.drone.DroneEvents;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.APMConstants;
-import org.droidplanner.services.android.core.drone.profiles.ParameterManager;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
-import org.droidplanner.services.android.core.drone.variables.Camera;
-import org.droidplanner.services.android.core.drone.variables.GuidedPoint;
-import org.droidplanner.services.android.core.drone.variables.HeartBeat;
-import org.droidplanner.services.android.core.drone.variables.MissionStats;
-import org.droidplanner.services.android.core.drone.variables.State;
-import org.droidplanner.services.android.core.drone.variables.StreamRates;
-import org.droidplanner.services.android.core.drone.variables.Type;
-import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.utils.CommonApiUtils;
-import org.droidplanner.services.android.utils.prefs.DroidPlannerPrefs;
-import org.droidplanner.services.android.utils.video.VideoManager;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkWaypoint;
+import org.droidplanner.services.android.impl.core.MAVLink.WaypointManager;
+import org.droidplanner.services.android.impl.core.drone.DroneEvents;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.APMConstants;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterManager;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.variables.Camera;
+import org.droidplanner.services.android.impl.core.drone.variables.GuidedPoint;
+import org.droidplanner.services.android.impl.core.drone.variables.HeartBeat;
+import org.droidplanner.services.android.impl.core.drone.variables.MissionStats;
+import org.droidplanner.services.android.impl.core.drone.variables.State;
+import org.droidplanner.services.android.impl.core.drone.variables.StreamRates;
+import org.droidplanner.services.android.impl.core.drone.variables.Type;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.AccelCalibration;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.utils.video.VideoManager;
/**
* Base drone implementation.
@@ -121,7 +120,7 @@ public GenericMavLinkDrone(String droneId, Context context, Handler handler, Dat
this.logListener = logListener;
- events = new DroneEvents(this, handler);
+ events = new DroneEvents(this);
heartbeat = initHeartBeat(handler);
this.type = new Type(this);
this.missionStats = new MissionStats(this);
@@ -129,7 +128,7 @@ public GenericMavLinkDrone(String droneId, Context context, Handler handler, Dat
this.state = new State(this, handler, warningParser);
parameterManager = new ParameterManager(this, context, handler);
- this.videoMgr = new VideoManager(context, handler);
+ this.videoMgr = new VideoManager(context, handler, mavClient);
}
@Override
@@ -148,7 +147,7 @@ public MissionStats getMissionStats() {
}
@Override
- public Mission getMission() {
+ public MissionImpl getMission() {
//TODO: complete implementation
return null;
}
@@ -298,17 +297,13 @@ protected void notifyAttributeListener(String attributeEvent) {
}
protected void notifyAttributeListener(String attributeEvent, Bundle eventInfo) {
- notifyAttributeListener(attributeEvent, eventInfo, false);
- }
-
- protected void notifyAttributeListener(String attributeEvent, Bundle eventInfo, boolean checkForSololinkApi) {
if (attributeListener != null) {
if(eventInfo == null){
eventInfo = new Bundle();
}
eventInfo.putString(AttributeEventExtra.EXTRA_VEHICLE_ID, getId());
- attributeListener.onAttributeEvent(attributeEvent, eventInfo, checkForSololinkApi);
+ attributeListener.onAttributeEvent(attributeEvent, eventInfo);
}
}
@@ -422,11 +417,11 @@ public boolean executeAsyncAction(Action action, ICommandListener listener) {
private boolean updateVehicleDataStreamRate(Bundle data, ICommandListener listener) {
StreamRates streamRates = getStreamRates();
if(streamRates != null){
- int rate = data.getInt(StateActions.EXTRA_VEHICLE_DATA_STREAM_RATE, DroidPlannerPrefs.DEFAULT_STREAM_RATE);
- StreamRates.Rates rates = new StreamRates.Rates(rate);
- streamRates.setRates(rates);
-
- streamRates.setupStreamRatesFromPref();
+ int rate = data.getInt(StateActions.EXTRA_VEHICLE_DATA_STREAM_RATE, -1);
+ if(rate != -1) {
+ StreamRates.Rates rates = new StreamRates.Rates(rate);
+ streamRates.setRates(rates);
+ }
CommonApiUtils.postSuccessEvent(listener);
return true;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/px4/Px4Native.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/px4/Px4Native.java
similarity index 55%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/px4/Px4Native.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/px4/Px4Native.java
index ef9ef5974d..05eb393f6b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/px4/Px4Native.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/autopilot/px4/Px4Native.java
@@ -1,15 +1,15 @@
-package org.droidplanner.services.android.core.drone.autopilot.px4;
+package org.droidplanner.services.android.impl.core.drone.autopilot.px4;
import android.content.Context;
import android.os.Handler;
import com.MAVLink.Messages.MAVLinkMessage;
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.drone.LogMessageListener;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.drone.LogMessageListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
/**
* Created by Fredia Huya-Kouadio on 9/10/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/manager/DroneCommandTracker.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/DroneCommandTracker.java
similarity index 98%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/manager/DroneCommandTracker.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/DroneCommandTracker.java
index 1aa348b63c..600b0f5d6e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/manager/DroneCommandTracker.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/DroneCommandTracker.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.manager;
+package org.droidplanner.services.android.impl.core.drone.manager;
import android.os.Handler;
import android.os.RemoteException;
@@ -7,6 +7,7 @@
import com.MAVLink.common.msg_command_ack;
import com.MAVLink.common.msg_command_long;
import com.MAVLink.common.msg_set_mode;
+
import com.o3dr.services.android.lib.model.ICommandListener;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/manager/MavLinkDroneManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/MavLinkDroneManager.java
similarity index 78%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/manager/MavLinkDroneManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/MavLinkDroneManager.java
index b0e22ad20f..8f598ffd9b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/manager/MavLinkDroneManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/manager/MavLinkDroneManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.manager;
+package org.droidplanner.services.android.impl.core.drone.manager;
import android.content.Context;
import android.os.Bundle;
@@ -16,44 +16,44 @@
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
-import com.o3dr.services.android.lib.gcs.follow.FollowLocationSource;
-import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.drone.property.DroneAttribute;
import com.o3dr.services.android.lib.gcs.action.FollowMeActions;
+import com.o3dr.services.android.lib.gcs.follow.FollowLocationSource;
import com.o3dr.services.android.lib.gcs.follow.FollowType;
+import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.gcs.returnToMe.ReturnToMeState;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.api.DroneApi;
-import org.droidplanner.services.android.communication.service.MAVLinkClient;
-import org.droidplanner.services.android.core.MAVLink.MavLinkMsgHandler;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneManager;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduCopter;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduPlane;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduRover;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.ArduSolo;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.px4.Px4Native;
-import org.droidplanner.services.android.core.drone.profiles.ParameterManager;
-import org.droidplanner.services.android.core.drone.variables.StreamRates;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.gcs.GCSHeartbeat;
-import org.droidplanner.services.android.core.gcs.ReturnToMe;
-import org.droidplanner.services.android.core.gcs.follow.Follow;
-import org.droidplanner.services.android.core.gcs.follow.FollowAlgorithm;
-import org.droidplanner.services.android.core.gcs.location.FusedLocation;
-import org.droidplanner.services.android.utils.AndroidApWarningParser;
-import org.droidplanner.services.android.utils.CommonApiUtils;
-import org.droidplanner.services.android.utils.SoloApiUtils;
-import org.droidplanner.services.android.utils.prefs.DroidPlannerPrefs;
+import org.droidplanner.services.android.impl.api.DroneApi;
+import org.droidplanner.services.android.impl.communication.service.MAVLinkClient;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkMsgHandler;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduCopter;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduPlane;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduRover;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.ArduSolo;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.px4.Px4Native;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterManager;
+import org.droidplanner.services.android.impl.core.drone.variables.StreamRates;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.gcs.GCSHeartbeat;
+import org.droidplanner.services.android.impl.core.gcs.ReturnToMe;
+import org.droidplanner.services.android.impl.core.gcs.follow.Follow;
+import org.droidplanner.services.android.impl.core.gcs.follow.FollowAlgorithm;
+import org.droidplanner.services.android.impl.core.gcs.location.FusedLocation;
+import org.droidplanner.services.android.impl.utils.AndroidApWarningParser;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.utils.SoloApiUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import timber.log.Timber;
@@ -62,6 +62,8 @@
*/
public class MavLinkDroneManager extends DroneManager implements MagnetometerCalibrationImpl.OnMagnetometerCalibrationListener {
+ private static final int DEFAULT_STREAM_RATE = 2; //Hz
+
private Follow followMe;
private ReturnToMe returnToMe;
@@ -71,6 +73,8 @@ public class MavLinkDroneManager extends DroneManager currentRate) {
+ updateComplete = droneStreamRate.compareAndSet(currentRate, eventsDispatchingRate);
+ if (updateComplete && drone != null) {
+ StreamRates rates = drone.getStreamRates();
+ if (rates != null) {
+ rates.setRates(new StreamRates.Rates(droneStreamRate.get()));
+ }
+ }
+ }
+ }while(!updateComplete);
}
@Override
@@ -184,7 +216,7 @@ protected void doDisconnect(String appId, DroneApi listener) {
}
if (listener != null) {
- mavClient.removeLoggingFile(appId);
+ mavClient.unregisterForTLogLogging(appId);
if (isConnected()) {
listener.onDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED, drone);
}
@@ -347,9 +379,7 @@ private void enableFollowMe(FollowType followType, FollowLocationSource source,
Timber.d("CURRENT: followMe.enabled=%s followMe.state=%s source=%s",
followMe.isEnabled(), followMe.getState(), source);
- if (!followMe.isEnabled()) {
- followMe.enableFollowMe(source);
- }
+ followMe.enableFollowMe(source);
FollowAlgorithm currentAlg = followMe.getFollowAlgorithm();
if (currentAlg.getType() != selectedMode) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterManager.java
similarity index 86%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterManager.java
index 414fb7aeff..75f046367a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.profiles;
+package org.droidplanner.services.android.impl.core.drone.profiles;
import android.content.Context;
import android.os.Handler;
@@ -9,17 +9,18 @@
import com.MAVLink.common.msg_param_value;
import com.o3dr.services.android.lib.drone.property.Parameter;
-import org.droidplanner.services.android.core.MAVLink.MavLinkParameters;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.utils.file.IO.ParameterMetadataLoader;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkParameters;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.utils.file.IO.ParameterMetadataLoader;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import timber.log.Timber;
@@ -58,6 +59,7 @@ public void run() {
};
private final AtomicBoolean isRefreshing = new AtomicBoolean(false);
+ private final ConcurrentLinkedQueue paramsToReadFromVehicle = new ConcurrentLinkedQueue<>();
private int expectedParams;
@@ -80,6 +82,7 @@ public ParameterManager(MavLinkDrone myDrone, Context context, Handler handler)
public void refreshParameters() {
if (isRefreshing.compareAndSet(false, true)) {
+ paramsToReadFromVehicle.clear();
expectedParams = 0;
parameters.clear();
paramsRollCall.clear();
@@ -115,12 +118,15 @@ public boolean processMessage(MAVLinkMessage msg) {
}
protected void processReceivedParam(msg_param_value m_value) {
+ String paramName = m_value.getParam_Id();
+ if(!paramsToReadFromVehicle.remove(paramName) && !isRefreshing.get())
+ return;
// collect params in parameter list
- Parameter param = new Parameter(m_value.getParam_Id(), m_value.param_value, m_value.param_type);
+ Parameter param = new Parameter(paramName, m_value.param_value, m_value.param_type);
loadParameterMetadata(param);
- parameters.put(param.getName().toLowerCase(Locale.US), param);
int paramIndex = m_value.param_index;
+ parameters.put(param.getName().toLowerCase(Locale.US), param);
if (paramIndex == -1) {
// update listener
notifyParameterReceipt(param, 0, 1);
@@ -137,9 +143,9 @@ protected void processReceivedParam(msg_param_value m_value) {
// Are all parameters here? Notify the listener with the parameters
if (parameters.size() >= m_value.param_count) {
- killWatchdog();
- isRefreshing.set(false);
-
+ if(isRefreshing.compareAndSet(true, false)) {
+ killWatchdog();
+ }
notifyParametersReceiptEnd();
} else {
resetWatchdog();
@@ -155,10 +161,12 @@ private void reRequestMissingParams(int howManyParams) {
}
public void sendParameter(Parameter parameter) {
+ paramsToReadFromVehicle.add(parameter.getName());
MavLinkParameters.sendParameter(myDrone, parameter);
}
public void readParameter(String name) {
+ paramsToReadFromVehicle.add(name);
MavLinkParameters.readParameter(myDrone, name);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterMetadata.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterMetadata.java
similarity index 84%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterMetadata.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterMetadata.java
index c91ad5d50d..fcadb911fe 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/ParameterMetadata.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/ParameterMetadata.java
@@ -1,10 +1,6 @@
-package org.droidplanner.services.android.core.drone.profiles;
+package org.droidplanner.services.android.impl.core.drone.profiles;
import java.io.Serializable;
-import java.text.DecimalFormat;
-import java.text.ParseException;
-import java.util.LinkedHashMap;
-import java.util.Map;
public class ParameterMetadata implements Serializable {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/VehicleProfile.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/VehicleProfile.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/VehicleProfile.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/VehicleProfile.java
index c5185dba3d..99169bc869 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/profiles/VehicleProfile.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/profiles/VehicleProfile.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.profiles;
+package org.droidplanner.services.android.impl.core.drone.profiles;
public class VehicleProfile {
private String parameterMetadataType;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/ApmModes.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/ApmModes.java
similarity index 98%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/ApmModes.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/ApmModes.java
index 89cb85de50..5246e570ea 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/ApmModes.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/ApmModes.java
@@ -1,10 +1,10 @@
-package org.droidplanner.services.android.core.drone.variables;
+package org.droidplanner.services.android.impl.core.drone.variables;
+
+import com.MAVLink.enums.MAV_TYPE;
import java.util.ArrayList;
import java.util.List;
-import com.MAVLink.enums.MAV_TYPE;
-
public enum ApmModes {
FIXED_WING_MANUAL (0,"Manual",MAV_TYPE.MAV_TYPE_FIXED_WING),
FIXED_WING_CIRCLE (1,"Circle",MAV_TYPE.MAV_TYPE_FIXED_WING),
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Camera.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Camera.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Camera.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Camera.java
index 8e6c2dabe5..ad29c679c3 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Camera.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Camera.java
@@ -1,22 +1,22 @@
-package org.droidplanner.services.android.core.drone.variables;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.core.survey.Footprint;
+package org.droidplanner.services.android.impl.core.drone.variables;
import com.MAVLink.ardupilotmega.msg_camera_feedback;
import com.MAVLink.ardupilotmega.msg_mount_status;
+
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.core.survey.Footprint;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.property.Altitude;
import com.o3dr.services.android.lib.drone.property.Attitude;
import com.o3dr.services.android.lib.drone.property.Gps;
+import java.util.ArrayList;
+import java.util.List;
+
public class Camera extends DroneVariable {
private CameraInfo camera = new CameraInfo();
private List footprints = new ArrayList();
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/GuidedPoint.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/GuidedPoint.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/GuidedPoint.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/GuidedPoint.java
index 6dc640e836..7f88143cda 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/GuidedPoint.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/GuidedPoint.java
@@ -1,8 +1,14 @@
-package org.droidplanner.services.android.core.drone.variables;
+package org.droidplanner.services.android.impl.core.drone.variables;
import android.os.Handler;
import android.os.RemoteException;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
@@ -11,13 +17,6 @@
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.SimpleCommandListener;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
import timber.log.Timber;
public class GuidedPoint extends DroneVariable implements OnDroneListener {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/HeartBeat.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/HeartBeat.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/HeartBeat.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/HeartBeat.java
index cc8814d1d7..76cf147ec5 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/HeartBeat.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/HeartBeat.java
@@ -1,14 +1,14 @@
-package org.droidplanner.services.android.core.drone.variables;
+package org.droidplanner.services.android.impl.core.drone.variables;
import android.os.Handler;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.common.msg_heartbeat;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import timber.log.Timber;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Magnetometer.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Magnetometer.java
similarity index 77%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Magnetometer.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Magnetometer.java
index 22f42e9e61..3c6f67179c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Magnetometer.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Magnetometer.java
@@ -1,10 +1,10 @@
-package org.droidplanner.services.android.core.drone.variables;
-
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.drone.variables;
import com.MAVLink.common.msg_raw_imu;
+
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.drone.property.Parameter;
public class Magnetometer extends DroneVariable {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/MissionStats.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/MissionStats.java
similarity index 75%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/MissionStats.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/MissionStats.java
index e108e314f2..10867f128b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/MissionStats.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/MissionStats.java
@@ -1,8 +1,8 @@
-package org.droidplanner.services.android.core.drone.variables;
+package org.droidplanner.services.android.impl.core.drone.variables;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
public class MissionStats extends DroneVariable {
private double distanceToWp = 0;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/RC.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/RC.java
similarity index 74%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/RC.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/RC.java
index db21dfaa8a..6910f41638 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/RC.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/RC.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.drone.variables;
-
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.drone.variables;
import com.MAVLink.common.msg_rc_channels_raw;
import com.MAVLink.common.msg_servo_output_raw;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
public class RC extends DroneVariable {
public int in[] = new int[8];
public int out[] = new int[8];
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/State.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/State.java
similarity index 91%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/State.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/State.java
index 1d9120757b..49860dca09 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/State.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/State.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.drone.variables;
+package org.droidplanner.services.android.impl.core.drone.variables;
import android.os.Handler;
import android.os.RemoteException;
@@ -6,18 +6,18 @@
import com.MAVLink.ardupilotmega.msg_ekf_status_report;
import com.MAVLink.enums.EKF_STATUS_FLAGS;
+
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.MAVLink.WaypointManager;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.MAVLink.WaypointManager;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
import timber.log.Timber;
public class State extends DroneVariable {
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/StreamRates.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/StreamRates.java
new file mode 100644
index 0000000000..3975a9b66d
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/StreamRates.java
@@ -0,0 +1,121 @@
+package org.droidplanner.services.android.impl.core.drone.variables;
+
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkStreamRates;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
+public class StreamRates extends DroneVariable implements OnDroneListener {
+
+ private Rates rates;
+
+ public StreamRates(MavLinkDrone myDrone) {
+ super(myDrone);
+ myDrone.addDroneListener(this);
+ }
+
+ public void setRates(Rates rates) {
+ if(this.rates == null || !this.rates.equals(rates)) {
+ this.rates = rates;
+ if (myDrone.isConnected() && myDrone.isConnectionAlive()) {
+ setupStreamRatesFromPref();
+ }
+ }
+ }
+
+ @Override
+ public void onDroneEvent(DroneEventsType event, MavLinkDrone drone) {
+ switch (event) {
+ case CONNECTED:
+ case HEARTBEAT_FIRST:
+ case HEARTBEAT_RESTORED:
+ setupStreamRatesFromPref();
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void setupStreamRatesFromPref() {
+ if(rates == null)
+ return;
+
+ MavLinkStreamRates.setupStreamRates(myDrone.getMavClient(), myDrone.getSysid(),
+ myDrone.getCompid(), rates.extendedStatus, rates.extra1, rates.extra2,
+ rates.extra3, rates.position, rates.rcChannels, rates.rawSensors,
+ rates.rawController);
+ }
+
+ public static class Rates {
+ public int extendedStatus;
+ public int extra1;
+ public int extra2;
+ public int extra3;
+ public int position;
+ public int rcChannels;
+ public int rawSensors;
+ public int rawController;
+
+ public Rates(int rate){
+ this.extendedStatus = rate;
+ this.extra1 = rate;
+ this.extra2 = rate;
+ this.extra3 = rate;
+ this.position = rate;
+ this.rcChannels = rate;
+ this.rawSensors = rate;
+ this.rawController = rate;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Rates)) {
+ return false;
+ }
+
+ Rates rates = (Rates) o;
+
+ if (extendedStatus != rates.extendedStatus) {
+ return false;
+ }
+ if (extra1 != rates.extra1) {
+ return false;
+ }
+ if (extra2 != rates.extra2) {
+ return false;
+ }
+ if (extra3 != rates.extra3) {
+ return false;
+ }
+ if (position != rates.position) {
+ return false;
+ }
+ if (rcChannels != rates.rcChannels) {
+ return false;
+ }
+ if (rawSensors != rates.rawSensors) {
+ return false;
+ }
+ return rawController == rates.rawController;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = extendedStatus;
+ result = 31 * result + extra1;
+ result = 31 * result + extra2;
+ result = 31 * result + extra3;
+ result = 31 * result + position;
+ result = 31 * result + rcChannels;
+ result = 31 * result + rawSensors;
+ result = 31 * result + rawController;
+ return result;
+ }
+ }
+
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Type.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Type.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Type.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Type.java
index c9a6ea698a..836c7b6185 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/Type.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/Type.java
@@ -1,13 +1,12 @@
-package org.droidplanner.services.android.core.drone.variables;
-
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+package org.droidplanner.services.android.impl.core.drone.variables;
import com.MAVLink.enums.MAV_TYPE;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+
public class Type extends DroneVariable implements DroneInterfaces.OnDroneListener{
private static final int DEFAULT_TYPE = MAV_TYPE.MAV_TYPE_GENERIC;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/AccelCalibration.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/AccelCalibration.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/AccelCalibration.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/AccelCalibration.java
index 11b40a376a..a26344259b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/AccelCalibration.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/AccelCalibration.java
@@ -1,19 +1,19 @@
-package org.droidplanner.services.android.core.drone.variables.calibration;
+package org.droidplanner.services.android.impl.core.drone.variables.calibration;
import android.os.Handler;
import android.os.RemoteException;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.common.msg_statustext;
+
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCalibration;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.SimpleCommandListener;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCalibration;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
import java.util.concurrent.atomic.AtomicReference;
import timber.log.Timber;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/MagnetometerCalibrationImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/MagnetometerCalibrationImpl.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/MagnetometerCalibrationImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/MagnetometerCalibrationImpl.java
index 7ab1fe3006..781daacc41 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/calibration/MagnetometerCalibrationImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/drone/variables/calibration/MagnetometerCalibrationImpl.java
@@ -1,13 +1,13 @@
-package org.droidplanner.services.android.core.drone.variables.calibration;
+package org.droidplanner.services.android.impl.core.drone.variables.calibration;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.ardupilotmega.msg_mag_cal_progress;
import com.MAVLink.ardupilotmega.msg_mag_cal_report;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCalibration;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCalibration;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/firmware/FirmwareType.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/firmware/FirmwareType.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/firmware/FirmwareType.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/firmware/FirmwareType.java
index 4069d10183..9863d0aa5e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/firmware/FirmwareType.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/firmware/FirmwareType.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.firmware;
+package org.droidplanner.services.android.impl.core.firmware;
import com.MAVLink.enums.MAV_AUTOPILOT;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/GCSHeartbeat.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/GCSHeartbeat.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/GCSHeartbeat.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/GCSHeartbeat.java
index 102aa5bf6f..0f76fcbd60 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/GCSHeartbeat.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/GCSHeartbeat.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.gcs;
+package org.droidplanner.services.android.impl.core.gcs;
import com.MAVLink.Messages.MAVLinkMessage;
import com.MAVLink.common.msg_heartbeat;
import com.MAVLink.enums.MAV_AUTOPILOT;
import com.MAVLink.enums.MAV_TYPE;
-import org.droidplanner.services.android.communication.model.DataLink;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/ReturnToMe.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/ReturnToMe.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/ReturnToMe.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/ReturnToMe.java
index b41e18f6f3..00e251f5bb 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/ReturnToMe.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/ReturnToMe.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.gcs;
+package org.droidplanner.services.android.impl.core.gcs;
import android.os.Bundle;
@@ -13,13 +13,13 @@
import com.o3dr.services.android.lib.model.ICommandListener;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
-import org.droidplanner.services.android.core.drone.DroneInterfaces;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.AttributeEventListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.utils.CommonApiUtils;
+import org.droidplanner.services.android.impl.core.MAVLink.command.doCmd.MavLinkDoCmds;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.AttributeEventListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.utils.CommonApiUtils;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -50,7 +50,6 @@ public class ReturnToMe implements DroneInterfaces.OnDroneListener
public ReturnToMe(MavLinkDroneManager droneMgr, Location.LocationFinder locationFinder, AttributeEventListener listener) {
this.droneMgr = droneMgr;
this.locationFinder = locationFinder;
- locationFinder.addLocationListener(TAG, this);
this.attributeListener = listener;
this.currentState = new ReturnToMeState();
@@ -201,7 +200,7 @@ private void updateCurrentState(@ReturnToMeState.ReturnToMeStates int state) {
if (attributeListener != null) {
final Bundle eventInfo = new Bundle();
eventInfo.putInt(AttributeEventExtra.EXTRA_RETURN_TO_ME_STATE, state);
- attributeListener.onAttributeEvent(AttributeEvent.RETURN_TO_ME_STATE_UPDATE, eventInfo, false);
+ attributeListener.onAttributeEvent(AttributeEvent.RETURN_TO_ME_STATE_UPDATE, eventInfo);
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/Follow.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/Follow.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/Follow.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/Follow.java
index be4f923ce4..3bafa2b95b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/Follow.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/Follow.java
@@ -1,6 +1,5 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
-import android.content.Context;
import android.os.Handler;
import com.o3dr.services.android.lib.drone.action.ControlActions;
@@ -8,16 +7,16 @@
import com.o3dr.services.android.lib.gcs.follow.FollowLocationSource;
import com.o3dr.services.android.lib.model.action.Action;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.ArduSolo;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.drone.variables.GuidedPoint;
-import org.droidplanner.services.android.core.drone.variables.State;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.gcs.location.Location.LocationFinder;
-import org.droidplanner.services.android.core.gcs.location.Location.LocationReceiver;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.OnDroneListener;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.ArduSolo;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.drone.variables.GuidedPoint;
+import org.droidplanner.services.android.impl.core.drone.variables.State;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.gcs.location.Location.LocationFinder;
+import org.droidplanner.services.android.impl.core.gcs.location.Location.LocationReceiver;
import timber.log.Timber;
@@ -25,7 +24,7 @@ public class Follow implements OnDroneListener, LocationReceiver {
private static final String TAG = Follow.class.getSimpleName();
private Location lastLocation;
- private FollowLocationSource mLocationSource = null;
+ private FollowLocationSource mLocationSource;
/**
* Set of return value for the 'toggleFollowMeState' method.
@@ -41,7 +40,7 @@ public enum FollowStates {
private FollowAlgorithm followAlgorithm;
private final LocationRelay mLocationRelay;
- public Follow(Context context, MavLinkDroneManager droneMgr, Handler handler, LocationFinder locationFinder) {
+ public Follow(MavLinkDroneManager droneMgr, Handler handler, LocationFinder locationFinder) {
this.droneMgr = droneMgr;
final MavLinkDrone drone = droneMgr.getDrone();
if(drone != null)
@@ -52,36 +51,36 @@ public Follow(Context context, MavLinkDroneManager droneMgr, Handler handler, Lo
FollowAlgorithm.FollowModes.LEASH.getAlgorithmType(droneMgr, handler);
this.locationFinder = locationFinder;
- locationFinder.addLocationListener(TAG, this);
-
mLocationRelay = new LocationRelay();
}
public void enableFollowMe(FollowLocationSource source) {
- final MavLinkDrone drone = droneMgr.getDrone();
- final State droneState = (drone != null)? drone.getState(): null;
-
- if(droneState == null) {
- Timber.w("No drone for enableFollowMe(%s)", source);
- state = FollowStates.FOLLOW_INVALID_STATE;
- return;
- }
+ if (!isEnabled()) {
+ final MavLinkDrone drone = droneMgr.getDrone();
+ final State droneState = (drone != null) ? drone.getState() : null;
+
+ if (droneState == null) {
+ Timber.w("No drone for enableFollowMe(%s)", source);
+ state = FollowStates.FOLLOW_INVALID_STATE;
+ return;
+ }
- if(droneMgr.isConnected()) {
- if(droneState.isArmed()) {
- GuidedPoint.changeToGuidedMode(drone, null);
- setLocationSource(source);
- state = FollowStates.FOLLOW_START;
- mLocationRelay.onFollowStart();
- followAlgorithm.enableFollow();
+ if (droneMgr.isConnected()) {
+ if (droneState.isArmed()) {
+ GuidedPoint.changeToGuidedMode(drone, null);
+ state = FollowStates.FOLLOW_START;
+ followAlgorithm.enableFollow();
- droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_START, null, false);
+ droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_START, null);
+ } else {
+ state = FollowStates.FOLLOW_DRONE_NOT_ARMED;
+ }
} else {
- state = FollowStates.FOLLOW_DRONE_NOT_ARMED;
+ state = FollowStates.FOLLOW_DRONE_DISCONNECTED;
}
- } else {
- state = FollowStates.FOLLOW_DRONE_DISCONNECTED;
}
+
+ setLocationSource(source);
}
public void disableFollowMe() {
@@ -89,15 +88,13 @@ public void disableFollowMe() {
followAlgorithm.disableFollow();
- if(mLocationSource == FollowLocationSource.INTERNAL) {
- locationFinder.disableLocationUpdates(TAG);
- }
+ setLocationSource(FollowLocationSource.NONE);
lastLocation = null;
if (isEnabled()) {
state = FollowStates.FOLLOW_END;
- droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_STOP, null, false);
+ droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_STOP, null);
}
final MavLinkDrone drone = droneMgr.getDrone();
@@ -158,7 +155,7 @@ public void onLocationUpdate(Location location) {
state = FollowStates.FOLLOW_START;
}
- droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_UPDATE, null, false);
+ droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_UPDATE, null);
}
@Override
@@ -183,7 +180,7 @@ public void setAlgorithm(FollowAlgorithm algorithm) {
followAlgorithm.onLocationReceived(lastLocation);
}
- droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_UPDATE, null, false);
+ droneMgr.onAttributeEvent(AttributeEvent.FOLLOW_UPDATE, null);
}
public FollowAlgorithm getFollowAlgorithm() {
@@ -195,11 +192,15 @@ public FollowStates getState() {
}
private void setLocationSource(FollowLocationSource source) {
+ if(!isEnabled())
+ return;
+
if(mLocationSource != source) {
switch(source) {
case CLIENT_SPECIFIED: {
Timber.d("Switch to client-specified locations");
locationFinder.disableLocationUpdates(TAG);
+ mLocationRelay.onFollowStart();
break;
}
@@ -208,6 +209,12 @@ private void setLocationSource(FollowLocationSource source) {
locationFinder.enableLocationUpdates(TAG, this);
break;
}
+
+ case NONE:
+ default:{
+ locationFinder.disableLocationUpdates(TAG);
+ break;
+ }
}
mLocationSource = source;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAbove.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAbove.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAbove.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAbove.java
index abba4c9076..f5642ef3c6 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAbove.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAbove.java
@@ -1,13 +1,12 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
public class FollowAbove extends FollowAlgorithm {
protected final MavLinkDrone drone;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAlgorithm.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAlgorithm.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAlgorithm.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAlgorithm.java
index 60c8fffa99..7f2ea387b0 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowAlgorithm.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowAlgorithm.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.gcs.roi.ROIEstimator;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.gcs.roi.ROIEstimator;
import java.util.Collections;
import java.util.Map;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowCircle.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowCircle.java
similarity index 75%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowCircle.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowCircle.java
index dff589bb38..8a95b929ce 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowCircle.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowCircle.java
@@ -1,14 +1,13 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.util.MathUtils;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-
public class FollowCircle extends FollowWithRadiusAlgorithm {
/**
* °/s
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowGuidedScan.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowGuidedScan.java
similarity index 87%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowGuidedScan.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowGuidedScan.java
index c83292cdec..91e6b688d1 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowGuidedScan.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowGuidedScan.java
@@ -1,15 +1,14 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.MAVLink.command.doCmd.MavLinkDoCmds;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.roi.ROIEstimator;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.roi.ROIEstimator;
-
import java.util.HashMap;
import java.util.Map;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowHeadingAngle.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowHeadingAngle.java
similarity index 68%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowHeadingAngle.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowHeadingAngle.java
index 5c71d0f93f..7fa5a5f5d5 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowHeadingAngle.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowHeadingAngle.java
@@ -1,14 +1,13 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
public abstract class FollowHeadingAngle extends FollowWithRadiusAlgorithm {
protected double angleOffset;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLead.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLead.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLead.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLead.java
index f9e1517aeb..7527c06dcd 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLead.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLead.java
@@ -1,8 +1,8 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
public class FollowLead extends FollowHeadingAngle {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeash.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeash.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeash.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeash.java
index 86320669c6..afcb2dbafe 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeash.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeash.java
@@ -1,15 +1,14 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.property.Gps;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-
public class FollowLeash extends FollowWithRadiusAlgorithm {
public FollowLeash(MavLinkDroneManager droneMgr, Handler handler, double radius) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeft.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeft.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeft.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeft.java
index cf0c8d65ec..d776973128 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLeft.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLeft.java
@@ -1,8 +1,8 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
public class FollowLeft extends FollowHeadingAngle {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLookAtMe.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLookAtMe.java
similarity index 65%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLookAtMe.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLookAtMe.java
index ed1d197b4e..1c903f667b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowLookAtMe.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowLookAtMe.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
/**
* Created by Fredia Huya-Kouadio on 3/23/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowRight.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowRight.java
similarity index 68%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowRight.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowRight.java
index aee1a07c4f..f12254ca1f 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowRight.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowRight.java
@@ -1,8 +1,8 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
public class FollowRight extends FollowHeadingAngle {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSoloShot.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSoloShot.java
similarity index 83%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSoloShot.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSoloShot.java
index d79a676e92..50601733ee 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSoloShot.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSoloShot.java
@@ -1,18 +1,17 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.ArduSolo;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.SoloComp;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.gcs.roi.ROIEstimator;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.drone.companion.solo.tlv.SoloMessageLocation;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.ArduSolo;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.SoloComp;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.gcs.roi.ROIEstimator;
-
/**
* Created by Fredia Huya-Kouadio on 8/3/15.
*/
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineAbove.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineAbove.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineAbove.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineAbove.java
index 7a504557be..ddd6ae6b02 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineAbove.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineAbove.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
/**
* Created by fhuya on 1/5/15.
@@ -19,7 +19,6 @@ public class FollowSplineAbove extends FollowAlgorithm {
public void processNewLocation(Location location) {
LatLong gcsLoc = new LatLong(location.getCoord());
- //TODO: some device (nexus 6) do not report the speed (always 0).. figure out workaround.
double speed = location.getSpeed();
double bearing = location.getBearing();
double bearingInRad = Math.toRadians(bearing);
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineLeash.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineLeash.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineLeash.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineLeash.java
index 7f23b8bab5..27b8d65f6c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowSplineLeash.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowSplineLeash.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
@@ -7,9 +7,9 @@
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.property.Gps;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
/**
* Created by fhuya on 1/5/15.
@@ -29,7 +29,6 @@ public void processNewLocation(Location location) {
double headingGCSToDrone = GeoTools.getHeadingFromCoordinates(userLoc, droneLoc);
LatLong goCoord = GeoTools.newCoordFromBearingAndDistance(userLoc, headingGCSToDrone, radius);
- //TODO: some device (nexus 6) do not report the speed (always 0).. figure out workaround.
double speed = location.getSpeed();
double bearing = location.getBearing();
double bearingInRad = Math.toRadians(bearing);
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowWithRadiusAlgorithm.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowWithRadiusAlgorithm.java
similarity index 81%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowWithRadiusAlgorithm.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowWithRadiusAlgorithm.java
index 6156c5e119..c996ccaf98 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/FollowWithRadiusAlgorithm.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/FollowWithRadiusAlgorithm.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import android.os.Handler;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.manager.MavLinkDroneManager;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.manager.MavLinkDroneManager;
import java.util.HashMap;
import java.util.Map;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/LocationRelay.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/LocationRelay.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/LocationRelay.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/LocationRelay.java
index ccb3a13800..dc31bd61bf 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/follow/LocationRelay.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/follow/LocationRelay.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.core.gcs.follow;
+package org.droidplanner.services.android.impl.core.gcs.follow;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
import timber.log.Timber;
@@ -26,10 +26,6 @@ public static String getLatLongFromLocation(final android.location.Location loca
private float mTotalSpeed = 0;
private int mSpeedReadings = 0;
- public LocationRelay() {
- super();
- }
-
public void onFollowStart() {
mTotalSpeed = 0;
mSpeedReadings = 0;
@@ -40,6 +36,9 @@ public void onFollowStart() {
* Convert the specified Android location to a local Location, and track speed/accuracy
*/
public Location toGcsLocation(android.location.Location androidLocation) {
+ if(androidLocation == null)
+ return null;
+
Location gcsLocation = null;
if(VERBOSE) Timber.d("toGcsLocation(): followLoc=" + androidLocation);
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/location/FusedLocation.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/FusedLocation.java
similarity index 89%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/location/FusedLocation.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/FusedLocation.java
index 70c94626f6..b07fbaff1f 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/location/FusedLocation.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/FusedLocation.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.gcs.location;
+package org.droidplanner.services.android.impl.core.gcs.location;
import android.content.Context;
import android.location.Location;
@@ -15,9 +15,9 @@
import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager;
import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask;
-import org.droidplanner.services.android.core.gcs.follow.LocationRelay;
-import org.droidplanner.services.android.core.gcs.location.Location.LocationFinder;
-import org.droidplanner.services.android.core.gcs.location.Location.LocationReceiver;
+import org.droidplanner.services.android.impl.core.gcs.follow.LocationRelay;
+import org.droidplanner.services.android.impl.core.gcs.location.Location.LocationFinder;
+import org.droidplanner.services.android.impl.core.gcs.location.Location.LocationReceiver;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -81,8 +81,8 @@ protected void doRun() {
@Override
public void enableLocationUpdates(String tag, LocationReceiver receiver) {
+ receivers.put(tag, receiver);
if(!mLocationUpdatesEnabled) {
- receivers.put(tag, receiver);
gApiMgr.start();
locationRelay.onFollowStart();
mLocationUpdatesEnabled = true;
@@ -92,11 +92,11 @@ public void enableLocationUpdates(String tag, LocationReceiver receiver) {
@Override
public void disableLocationUpdates(String tag) {
if(mLocationUpdatesEnabled) {
- receivers.remove(tag);
gApiMgr.addTask(removeLocationUpdate);
gApiMgr.stopSafely();
mLocationUpdatesEnabled = false;
}
+ receivers.remove(tag);
}
@Override
@@ -112,15 +112,18 @@ public void onLocationResult(LocationResult result) {
if (androidLocation == null)
return;
- org.droidplanner.services.android.core.gcs.location.Location gcsLocation =
+ org.droidplanner.services.android.impl.core.gcs.location.Location gcsLocation =
locationRelay.toGcsLocation(androidLocation);
+ if(gcsLocation == null)
+ return;
+
Timber.d("Location Lat/Long: " + LocationRelay.getLatLongFromLocation(androidLocation));
notifyLocationUpdate(gcsLocation);
}
- private void notifyLocationUpdate(org.droidplanner.services.android.core.gcs.location.Location location) {
+ private void notifyLocationUpdate(org.droidplanner.services.android.impl.core.gcs.location.Location location) {
if (receivers.isEmpty()) {
Timber.d(TAG, "notifyLocationUpdate(): No receivers");
return;
@@ -131,16 +134,6 @@ private void notifyLocationUpdate(org.droidplanner.services.android.core.gcs.loc
}
}
- @Override
- public void addLocationListener(String tag, LocationReceiver receiver) {
- receivers.put(tag, receiver);
- }
-
- @Override
- public void removeLocationListener(String tag) {
- receivers.remove(tag);
- }
-
@Override
public void onGoogleApiConnectionError(ConnectionResult result) {
notifyLocationUnavailable();
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/location/Location.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/Location.java
similarity index 87%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/location/Location.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/Location.java
index ad3ec4e232..5636bb4759 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/location/Location.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/location/Location.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.gcs.location;
+package org.droidplanner.services.android.impl.core.gcs.location;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
@@ -13,9 +13,6 @@ public interface LocationReceiver {
public interface LocationFinder {
void enableLocationUpdates(String tag, LocationReceiver receiver);
void disableLocationUpdates(String tag);
-
- void addLocationListener(String tag, LocationReceiver receiver);
- void removeLocationListener(String tag);
}
private LatLongAlt coordinate;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/package-info.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/package-info.java
similarity index 64%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/package-info.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/package-info.java
index 3e9e6cbe7f..34d13ef5b1 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/package-info.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/package-info.java
@@ -1,4 +1,4 @@
/**
* This package contains code and logic related to the ground control station functionality.
*/
-package org.droidplanner.services.android.core.gcs;
\ No newline at end of file
+package org.droidplanner.services.android.impl.core.gcs;
\ No newline at end of file
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/gcs/roi/ROIEstimator.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/roi/ROIEstimator.java
similarity index 85%
rename from ServiceApp/src/org/droidplanner/services/android/core/gcs/roi/ROIEstimator.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/roi/ROIEstimator.java
index 7b8a8b8fb3..c35254a868 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/gcs/roi/ROIEstimator.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/gcs/roi/ROIEstimator.java
@@ -1,16 +1,15 @@
-package org.droidplanner.services.android.core.gcs.roi;
+package org.droidplanner.services.android.impl.core.gcs.roi;
import android.os.Handler;
+import org.droidplanner.services.android.impl.core.MAVLink.command.doCmd.MavLinkDoCmds;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.gcs.location.Location;
+import org.droidplanner.services.android.impl.core.gcs.location.Location.LocationReceiver;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.gcs.location.Location;
-import org.droidplanner.services.android.core.gcs.location.Location.LocationReceiver;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-
import java.util.concurrent.atomic.AtomicBoolean;
/**
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/coordinates/CoordBounds.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBounds.java
similarity index 90%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/coordinates/CoordBounds.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBounds.java
index c6d19f86e1..00dd39e474 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/coordinates/CoordBounds.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/coordinates/CoordBounds.java
@@ -1,11 +1,10 @@
-package org.droidplanner.services.android.core.helpers.coordinates;
+package org.droidplanner.services.android.impl.core.helpers.coordinates;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-
/**
* Calculate a rectangle that bounds all inserted points
*/
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/GeoTools.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoTools.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/GeoTools.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoTools.java
index 487b54e967..142607b3d1 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/GeoTools.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/GeoTools.java
@@ -1,12 +1,11 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
+import org.droidplanner.services.android.impl.core.helpers.units.Area;
+import org.droidplanner.services.android.impl.core.polygon.Polygon;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import com.o3dr.services.android.lib.util.MathUtils;
-import org.droidplanner.services.android.core.helpers.units.Area;
-import org.droidplanner.services.android.core.polygon.Polygon;
-
import java.util.List;
import static java.lang.Math.PI;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineLatLong.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineLatLong.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineLatLong.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineLatLong.java
index 9158204156..509ea9c5d0 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineLatLong.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineLatLong.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineSampler.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineSampler.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineSampler.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineSampler.java
index 27fe9d0cf9..213160186a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineSampler.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineSampler.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineTools.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineTools.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineTools.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineTools.java
index 1c7e94bb6f..bf155f5c03 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/LineTools.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/LineTools.java
@@ -1,12 +1,11 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
+import org.droidplanner.services.android.impl.core.helpers.coordinates.CoordBounds;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.ArrayList;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.coordinates.CoordBounds;
-
public class LineTools {
public static LineLatLong findExternalPoints(ArrayList crosses) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PointTools.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PointTools.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PointTools.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PointTools.java
index 249e04983a..0fc5e4e75c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PointTools.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PointTools.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PolylineTools.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PolylineTools.java
similarity index 89%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PolylineTools.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PolylineTools.java
index 4d90a6ea52..1649eadbff 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/PolylineTools.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/PolylineTools.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/Simplify.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/Simplify.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/Simplify.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/Simplify.java
index 8fb8440764..8ee6cfb75e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/Simplify.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/Simplify.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools;
+package org.droidplanner.services.android.impl.core.helpers.geoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/Spline.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/Spline.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/Spline.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/Spline.java
index 202ebf756f..cbc9f1c7fb 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/Spline.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/Spline.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools.spline;
+package org.droidplanner.services.android.impl.core.helpers.geoTools.spline;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/SplinePath.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/SplinePath.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/SplinePath.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/SplinePath.java
index 6dc89c5c2d..5926309855 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/geoTools/spline/SplinePath.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/geoTools/spline/SplinePath.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.geoTools.spline;
+package org.droidplanner.services.android.impl.core.helpers.geoTools.spline;
import com.o3dr.services.android.lib.coordinate.LatLong;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/helpers/units/Area.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/units/Area.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/helpers/units/Area.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/units/Area.java
index 34c3d951a5..da86121aa0 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/helpers/units/Area.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/helpers/units/Area.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.helpers.units;
+package org.droidplanner.services.android.impl.core.helpers.units;
import java.util.Locale;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/Mission.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionImpl.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/Mission.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionImpl.java
index 73eb58aa3c..ee1e900079 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/Mission.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionImpl.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.mission;
+package org.droidplanner.services.android.impl.core.mission;
import android.util.Pair;
@@ -14,27 +14,19 @@
import com.o3dr.services.android.lib.drone.property.Home;
import com.o3dr.services.android.lib.drone.property.Parameter;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.apm.APMConstants;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.mission.commands.CameraTriggerImpl;
-import org.droidplanner.services.android.core.mission.commands.ChangeSpeedImpl;
-import org.droidplanner.services.android.core.mission.commands.ConditionYawImpl;
-import org.droidplanner.services.android.core.mission.commands.DoJumpImpl;
-import org.droidplanner.services.android.core.mission.commands.EpmGripperImpl;
-import org.droidplanner.services.android.core.mission.commands.ReturnToHomeImpl;
-import org.droidplanner.services.android.core.mission.commands.SetRelayImpl;
-import org.droidplanner.services.android.core.mission.commands.SetServoImpl;
-import org.droidplanner.services.android.core.mission.commands.TakeoffImpl;
-import org.droidplanner.services.android.core.mission.waypoints.CircleImpl;
-import org.droidplanner.services.android.core.mission.waypoints.DoLandStartImpl;
-import org.droidplanner.services.android.core.mission.waypoints.LandImpl;
-import org.droidplanner.services.android.core.mission.waypoints.RegionOfInterestImpl;
-import org.droidplanner.services.android.core.mission.waypoints.SpatialCoordItem;
-import org.droidplanner.services.android.core.mission.waypoints.SplineWaypointImpl;
-import org.droidplanner.services.android.core.mission.waypoints.WaypointImpl;
+import org.droidplanner.services.android.impl.core.drone.DroneInterfaces.DroneEventsType;
+import org.droidplanner.services.android.impl.core.drone.DroneVariable;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.APMConstants;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.mission.commands.ChangeSpeedImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ReturnToHomeImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.TakeoffImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.LandImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.RegionOfInterestImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.SpatialCoordItem;
+import org.droidplanner.services.android.impl.core.mission.waypoints.WaypointImpl;
+import org.droidplanner.services.android.impl.utils.MissionUtils;
import java.util.ArrayList;
import java.util.Collections;
@@ -44,7 +36,7 @@
* This implements a mavlink mission. A mavlink mission is a set of
* commands/mission items to be carried out by the drone.
*/
-public class Mission extends DroneVariable {
+public class MissionImpl extends DroneVariable {
/**
* Stores the set of mission items belonging to this mission.
@@ -52,7 +44,7 @@ public class Mission extends DroneVariable {
private List items = new ArrayList();
private final List componentItems = new ArrayList<>();
- public Mission(GenericMavLinkDrone myDrone) {
+ public MissionImpl(GenericMavLinkDrone myDrone) {
super(myDrone);
}
@@ -107,8 +99,7 @@ public void addMissionItem(int index, MissionItemImpl missionItemImpl) {
}
/**
- * Signals that this mission object was updated. //TODO: maybe move outside
- * of this class
+ * Signals that this mission object was updated.
*/
public void notifyMissionUpdate() {
updateComponentItems();
@@ -215,7 +206,7 @@ public void onMissionReceived(List msgs) {
myDrone.processHomeUpdate(msgs.get(0));
msgs.remove(0); // Remove Home waypoint
items.clear();
- items.addAll(processMavLinkMessages(msgs));
+ items.addAll(MissionUtils.processMavLinkMessages(this, msgs));
myDrone.notifyDroneEvent(DroneEventsType.MISSION_RECEIVED);
notifyMissionUpdate();
}
@@ -226,69 +217,12 @@ public void onMissionLoaded(List msgs) {
myDrone.processHomeUpdate(msgs.get(0));
msgs.remove(0); // Remove Home waypoint
items.clear();
- items.addAll(processMavLinkMessages(msgs));
+ items.addAll(MissionUtils.processMavLinkMessages(this, msgs));
myDrone.notifyDroneEvent(DroneEventsType.MISSION_RECEIVED);
notifyMissionUpdate();
}
}
- private List processMavLinkMessages(List msgs) {
- List received = new ArrayList();
- for (msg_mission_item msg : msgs) {
- switch (msg.command) {
- case MAV_CMD.MAV_CMD_DO_SET_SERVO:
- received.add(new SetServoImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_WAYPOINT:
- received.add(new WaypointImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_SPLINE_WAYPOINT:
- received.add(new SplineWaypointImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_LAND:
- received.add(new LandImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_LAND_START:
- received.add(new DoLandStartImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_TAKEOFF:
- received.add(new TakeoffImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_CHANGE_SPEED:
- received.add(new ChangeSpeedImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_SET_CAM_TRIGG_DIST:
- received.add(new CameraTriggerImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_GRIPPER:
- received.add(new EpmGripperImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_SET_ROI:
- received.add(new RegionOfInterestImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_LOITER_TURNS:
- received.add(new CircleImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_NAV_RETURN_TO_LAUNCH:
- received.add(new ReturnToHomeImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_CONDITION_YAW:
- received.add(new ConditionYawImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_SET_RELAY:
- received.add(new SetRelayImpl(msg, this));
- break;
- case MAV_CMD.MAV_CMD_DO_JUMP:
- received.add(new DoJumpImpl(msg, this));
- break;
-
- default:
- break;
- }
- }
- return received;
- }
-
/**
* Sends the mission to the drone using the mavlink protocol.
*/
@@ -312,7 +246,7 @@ private void updateComponentItems(List msgMissionItems) {
if(firstItem.seq == APMConstants.HOME_WAYPOINT_INDEX) {
msgMissionItems.remove(0); // Remove Home waypoint
}
- componentItems.addAll(processMavLinkMessages(msgMissionItems));
+ componentItems.addAll(MissionUtils.processMavLinkMessages(this, msgMissionItems));
}
public msg_mission_item packHomeMavlink() {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemImpl.java
similarity index 74%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemImpl.java
index e191a82fc6..303a5f74d5 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemImpl.java
@@ -1,21 +1,21 @@
-package org.droidplanner.services.android.core.mission;
-
-import java.util.ArrayList;
-import java.util.List;
+package org.droidplanner.services.android.impl.core.mission;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_FRAME;
+import java.util.ArrayList;
+import java.util.List;
+
public abstract class MissionItemImpl implements Comparable {
- protected Mission mission;
+ protected MissionImpl missionImpl;
- public MissionItemImpl(Mission mission) {
- this.mission = mission;
+ public MissionItemImpl(MissionImpl missionImpl) {
+ this.missionImpl = missionImpl;
}
public MissionItemImpl(MissionItemImpl item) {
- this(item.mission);
+ this(item.missionImpl);
}
/**
@@ -42,13 +42,13 @@ public List packMissionItem() {
public abstract MissionItemType getType();
- public Mission getMission() {
- return mission;
+ public MissionImpl getMission() {
+ return missionImpl;
}
@Override
public int compareTo(MissionItemImpl another) {
- return mission.getOrder(this) - mission.getOrder(another);
+ return missionImpl.getOrder(this) - missionImpl.getOrder(another);
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemType.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemType.java
similarity index 63%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemType.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemType.java
index 74bee68cad..294ad4ad6d 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/MissionItemType.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/MissionItemType.java
@@ -1,26 +1,25 @@
-package org.droidplanner.services.android.core.mission;
+package org.droidplanner.services.android.impl.core.mission;
+import org.droidplanner.services.android.impl.core.mission.commands.CameraTriggerImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ChangeSpeedImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ConditionYawImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.DoJumpImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.EpmGripperImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ReturnToHomeImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetRelayImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetServoImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.TakeoffImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SplineSurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.CircleImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.DoLandStartImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.LandImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.RegionOfInterestImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.SplineWaypointImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.StructureScannerImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.WaypointImpl;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.mission.commands.CameraTriggerImpl;
-import org.droidplanner.services.android.core.mission.commands.ChangeSpeedImpl;
-import org.droidplanner.services.android.core.mission.commands.ConditionYawImpl;
-import org.droidplanner.services.android.core.mission.commands.DoJumpImpl;
-import org.droidplanner.services.android.core.mission.commands.EpmGripperImpl;
-import org.droidplanner.services.android.core.mission.commands.ReturnToHomeImpl;
-import org.droidplanner.services.android.core.mission.commands.SetRelayImpl;
-import org.droidplanner.services.android.core.mission.commands.SetServoImpl;
-import org.droidplanner.services.android.core.mission.commands.TakeoffImpl;
-import org.droidplanner.services.android.core.mission.survey.SplineSurveyImpl;
-import org.droidplanner.services.android.core.mission.survey.SurveyImpl;
-import org.droidplanner.services.android.core.mission.waypoints.CircleImpl;
-import org.droidplanner.services.android.core.mission.waypoints.DoLandStartImpl;
-import org.droidplanner.services.android.core.mission.waypoints.LandImpl;
-import org.droidplanner.services.android.core.mission.waypoints.RegionOfInterestImpl;
-import org.droidplanner.services.android.core.mission.waypoints.SplineWaypointImpl;
-import org.droidplanner.services.android.core.mission.waypoints.StructureScannerImpl;
-import org.droidplanner.services.android.core.mission.waypoints.WaypointImpl;
-
import java.util.Collections;
public enum MissionItemType {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/CameraTriggerImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/CameraTriggerImpl.java
similarity index 67%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/CameraTriggerImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/CameraTriggerImpl.java
index faeec3a667..82e1502e3f 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/CameraTriggerImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/CameraTriggerImpl.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import java.util.List;
@@ -16,13 +16,13 @@ public CameraTriggerImpl(MissionItemImpl item) {
super(item);
}
- public CameraTriggerImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public CameraTriggerImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public CameraTriggerImpl(Mission mission, double triggerDistance) {
- super(mission);
+ public CameraTriggerImpl(MissionImpl missionImpl, double triggerDistance) {
+ super(missionImpl);
this.distance = triggerDistance;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ChangeSpeedImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ChangeSpeedImpl.java
similarity index 70%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ChangeSpeedImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ChangeSpeedImpl.java
index 14bc22bdb6..b034aea83a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ChangeSpeedImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ChangeSpeedImpl.java
@@ -1,15 +1,15 @@
-package org.droidplanner.services.android.core.mission.commands;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+
+import java.util.List;
+
public class ChangeSpeedImpl extends MissionCMD {
private double speed = 5; //meters per second
@@ -17,13 +17,13 @@ public ChangeSpeedImpl(MissionItemImpl item) {
super(item);
}
- public ChangeSpeedImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public ChangeSpeedImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public ChangeSpeedImpl(Mission mission, double speed) {
- super(mission);
+ public ChangeSpeedImpl(MissionImpl missionImpl, double speed) {
+ super(missionImpl);
this.speed = speed;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ConditionYawImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ConditionYawImpl.java
similarity index 72%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ConditionYawImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ConditionYawImpl.java
index cef4ca8ec3..6715c71e2b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ConditionYawImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ConditionYawImpl.java
@@ -1,15 +1,15 @@
-package org.droidplanner.services.android.core.mission.commands;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+
+import java.util.List;
+
public class ConditionYawImpl extends MissionCMD {
private boolean isRelative = false;
private double angle = 0;
@@ -19,13 +19,13 @@ public ConditionYawImpl(MissionItemImpl item) {
super(item);
}
- public ConditionYawImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public ConditionYawImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public ConditionYawImpl(Mission mission, double angle, boolean isRelative) {
- super(mission);
+ public ConditionYawImpl(MissionImpl missionImpl, double angle, boolean isRelative) {
+ super(missionImpl);
setAngle(angle);
setRelative(isRelative);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/DoJumpImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/DoJumpImpl.java
similarity index 70%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/DoJumpImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/DoJumpImpl.java
index eeac162bf0..3e49bfe411 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/DoJumpImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/DoJumpImpl.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import java.util.List;
@@ -20,17 +20,17 @@ public DoJumpImpl(MissionItemImpl item){
super(item);
}
- public DoJumpImpl(Mission mission) {
- super(mission);
+ public DoJumpImpl(MissionImpl missionImpl) {
+ super(missionImpl);
}
- public DoJumpImpl(msg_mission_item mavMsg, Mission mission){
- super(mission);
+ public DoJumpImpl(msg_mission_item mavMsg, MissionImpl missionImpl){
+ super(missionImpl);
unpackMAVMessage(mavMsg);
}
- public DoJumpImpl(Mission mission, int waypoint, int repeatCount){
- super(mission);
+ public DoJumpImpl(MissionImpl missionImpl, int waypoint, int repeatCount){
+ super(missionImpl);
this.waypoint = waypoint;
this.repeatCount = repeatCount;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/EpmGripperImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/EpmGripperImpl.java
similarity index 70%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/EpmGripperImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/EpmGripperImpl.java
index 2022770490..6f2b556757 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/EpmGripperImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/EpmGripperImpl.java
@@ -1,15 +1,15 @@
-package org.droidplanner.services.android.core.mission.commands;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.GRIPPER_ACTIONS;
import com.MAVLink.enums.MAV_CMD;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+
+import java.util.List;
+
public class EpmGripperImpl extends MissionCMD {
private boolean release = true;
@@ -18,13 +18,13 @@ public EpmGripperImpl(MissionItemImpl item) {
super(item);
}
- public EpmGripperImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public EpmGripperImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public EpmGripperImpl(Mission mission, boolean release) {
- super(mission);
+ public EpmGripperImpl(MissionImpl missionImpl, boolean release) {
+ super(missionImpl);
this.release = release;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/MissionCMD.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/MissionCMD.java
similarity index 51%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/MissionCMD.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/MissionCMD.java
index f346e4d76e..7d1ddb71aa 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/MissionCMD.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/MissionCMD.java
@@ -1,16 +1,16 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
-import java.util.List;
+import com.MAVLink.common.msg_mission_item;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
-import com.MAVLink.common.msg_mission_item;
+import java.util.List;
public abstract class MissionCMD extends MissionItemImpl {
- public MissionCMD(Mission mission) {
- super(mission);
+ public MissionCMD(MissionImpl missionImpl) {
+ super(missionImpl);
}
public MissionCMD(MissionItemImpl item) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ReturnToHomeImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ReturnToHomeImpl.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ReturnToHomeImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ReturnToHomeImpl.java
index 2a8730e818..6121fd5cec 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/ReturnToHomeImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/ReturnToHomeImpl.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import java.util.List;
@@ -19,13 +19,13 @@ public ReturnToHomeImpl(MissionItemImpl item) {
returnAltitude = (0);
}
- public ReturnToHomeImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public ReturnToHomeImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public ReturnToHomeImpl(Mission mission) {
- super(mission);
+ public ReturnToHomeImpl(MissionImpl missionImpl) {
+ super(missionImpl);
returnAltitude = (0.0);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetRelayImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetRelayImpl.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetRelayImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetRelayImpl.java
index c0afc4020a..bef674b659 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetRelayImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetRelayImpl.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import java.util.List;
@@ -22,13 +22,13 @@ public SetRelayImpl(MissionItemImpl item){
super(item);
}
- public SetRelayImpl(msg_mission_item msg, Mission mission){
- super(mission);
+ public SetRelayImpl(msg_mission_item msg, MissionImpl missionImpl){
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public SetRelayImpl(Mission mission, int relayNumber, boolean enabled){
- super(mission);
+ public SetRelayImpl(MissionImpl missionImpl, int relayNumber, boolean enabled){
+ super(missionImpl);
this.relayNumber = relayNumber;
this.enabled = enabled;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetServoImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetServoImpl.java
similarity index 68%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetServoImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetServoImpl.java
index db1fce4349..eefbe7f5cf 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/SetServoImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/SetServoImpl.java
@@ -1,14 +1,14 @@
-package org.droidplanner.services.android.core.mission.commands;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+
+import java.util.List;
+
public class SetServoImpl extends MissionCMD {
private int pwm;
@@ -18,13 +18,13 @@ public SetServoImpl(MissionItemImpl item) {
super(item);
}
- public SetServoImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public SetServoImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public SetServoImpl(Mission mission, int channel, int pwm) {
- super(mission);
+ public SetServoImpl(MissionImpl missionImpl, int channel, int pwm) {
+ super(missionImpl);
this.channel = channel;
this.pwm = pwm;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/TakeoffImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/TakeoffImpl.java
similarity index 72%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/commands/TakeoffImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/TakeoffImpl.java
index e0d84f5870..a0cd0fd0c3 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/commands/TakeoffImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/commands/TakeoffImpl.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.mission.commands;
+package org.droidplanner.services.android.impl.core.mission.commands;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import java.util.List;
@@ -21,19 +21,19 @@ public TakeoffImpl(MissionItemImpl item) {
super(item);
}
- public TakeoffImpl(msg_mission_item msg, Mission mission) {
- super(mission);
+ public TakeoffImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl);
unpackMAVMessage(msg);
}
- public TakeoffImpl(Mission mission, double altitude) {
- super(mission);
+ public TakeoffImpl(MissionImpl missionImpl, double altitude) {
+ super(missionImpl);
this.finishedAlt = altitude;
this.pitch = 0;
}
- public TakeoffImpl(Mission mission, double altitude, double pitch) {
- super(mission);
+ public TakeoffImpl(MissionImpl missionImpl, double altitude, double pitch) {
+ super(missionImpl);
this.finishedAlt = altitude;
this.pitch = pitch;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SplineSurveyImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SplineSurveyImpl.java
similarity index 74%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SplineSurveyImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SplineSurveyImpl.java
index 9a22fdd852..c9a7e4f663 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SplineSurveyImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SplineSurveyImpl.java
@@ -1,19 +1,19 @@
-package org.droidplanner.services.android.core.mission.survey;
+package org.droidplanner.services.android.impl.core.mission.survey;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
-import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.List;
public class SplineSurveyImpl extends SurveyImpl {
- public SplineSurveyImpl(Mission mission, List points) {
- super(mission, points);
+ public SplineSurveyImpl(MissionImpl missionImpl, List points) {
+ super(missionImpl, points);
}
@Override
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SurveyImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SurveyImpl.java
similarity index 81%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SurveyImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SurveyImpl.java
index 9202df55d7..3853529acc 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/survey/SurveyImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/survey/SurveyImpl.java
@@ -1,19 +1,19 @@
-package org.droidplanner.services.android.core.mission.survey;
+package org.droidplanner.services.android.impl.core.mission.survey;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
-import org.droidplanner.services.android.core.mission.commands.CameraTriggerImpl;
-import org.droidplanner.services.android.core.polygon.Polygon;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.core.survey.SurveyData;
-import org.droidplanner.services.android.core.survey.grid.Grid;
-import org.droidplanner.services.android.core.survey.grid.GridBuilder;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.commands.CameraTriggerImpl;
+import org.droidplanner.services.android.impl.core.polygon.Polygon;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.core.survey.SurveyData;
+import org.droidplanner.services.android.impl.core.survey.grid.Grid;
+import org.droidplanner.services.android.impl.core.survey.grid.GridBuilder;
import java.util.ArrayList;
import java.util.List;
@@ -26,8 +26,8 @@ public class SurveyImpl extends MissionItemImpl {
private boolean startCameraBeforeFirstWaypoint;
- public SurveyImpl(Mission mission, List points) {
- super(mission);
+ public SurveyImpl(MissionImpl missionImpl, List points) {
+ super(missionImpl);
polygon.addPoints(points);
}
@@ -71,7 +71,7 @@ public List packMissionItem() {
private void packSurveyPoints(List list) {
//Generate the camera trigger
- CameraTriggerImpl camTrigger = new CameraTriggerImpl(mission, surveyData.getLongitudinalPictureDistance());
+ CameraTriggerImpl camTrigger = new CameraTriggerImpl(missionImpl, surveyData.getLongitudinalPictureDistance());
//Add it if the user wants it to start before the first waypoint.
if(startCameraBeforeFirstWaypoint){
@@ -97,7 +97,7 @@ private void packSurveyPoints(List list) {
}
}
- list.addAll((new CameraTriggerImpl(mission, (0.0)).packMissionItem()));
+ list.addAll((new CameraTriggerImpl(missionImpl, (0.0)).packMissionItem()));
}
protected msg_mission_item getSurveyPoint(LatLong point, double altitude){
@@ -137,8 +137,6 @@ private msg_mission_item getYawCondition(double angle){
@Override
public void unpackMAVMessage(msg_mission_item mavMsg) {
- // TODO Auto-generated method stub
-
}
@Override
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/CircleImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/CircleImpl.java
similarity index 78%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/CircleImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/CircleImpl.java
index 3588ddafd0..2b6ed3fac5 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/CircleImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/CircleImpl.java
@@ -1,13 +1,13 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
import com.MAVLink.enums.MAV_FRAME;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import java.util.ArrayList;
import java.util.List;
@@ -21,12 +21,12 @@ public CircleImpl(MissionItemImpl item) {
super(item);
}
- public CircleImpl(Mission mission, LatLongAlt coord) {
- super(mission, coord);
+ public CircleImpl(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl, coord);
}
- public CircleImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public CircleImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/DoLandStartImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/DoLandStartImpl.java
similarity index 59%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/DoLandStartImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/DoLandStartImpl.java
index 3742576772..332566273b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/DoLandStartImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/DoLandStartImpl.java
@@ -1,14 +1,14 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
-
import java.util.List;
public class DoLandStartImpl extends SpatialCoordItem {
@@ -18,16 +18,16 @@ public DoLandStartImpl(MissionItemImpl item) {
setAltitude((0.0));
}
- public DoLandStartImpl(Mission mission) {
- this(mission, new LatLong(0, 0));
+ public DoLandStartImpl(MissionImpl missionImpl) {
+ this(missionImpl, new LatLong(0, 0));
}
- public DoLandStartImpl(Mission mMission, LatLong coord) {
- super(mMission, new LatLongAlt(coord, (0)));
+ public DoLandStartImpl(MissionImpl mMissionImpl, LatLong coord) {
+ super(mMissionImpl, new LatLongAlt(coord, (0)));
}
- public DoLandStartImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public DoLandStartImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/LandImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImpl.java
similarity index 59%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/LandImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImpl.java
index bdf7e55f24..c7b39acfec 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/LandImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/LandImpl.java
@@ -1,14 +1,14 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
-
import java.util.List;
public class LandImpl extends SpatialCoordItem {
@@ -18,16 +18,16 @@ public LandImpl(MissionItemImpl item) {
setAltitude((0.0));
}
- public LandImpl(Mission mission) {
- this(mission, new LatLong(0, 0));
+ public LandImpl(MissionImpl missionImpl) {
+ this(missionImpl, new LatLong(0, 0));
}
- public LandImpl(Mission mMission, LatLong coord) {
- super(mMission, new LatLongAlt(coord, 0));
+ public LandImpl(MissionImpl mMissionImpl, LatLong coord) {
+ super(mMissionImpl, new LatLongAlt(coord, 0));
}
- public LandImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public LandImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/RegionOfInterestImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/RegionOfInterestImpl.java
similarity index 65%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/RegionOfInterestImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/RegionOfInterestImpl.java
index 0ec6a2275c..9c862c5e57 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/RegionOfInterestImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/RegionOfInterestImpl.java
@@ -1,27 +1,27 @@
-package org.droidplanner.services.android.core.mission.waypoints;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
+import java.util.List;
+
public class RegionOfInterestImpl extends SpatialCoordItem {
public RegionOfInterestImpl(MissionItemImpl item) {
super(item);
}
- public RegionOfInterestImpl(Mission mission, LatLongAlt coord) {
- super(mission,coord);
+ public RegionOfInterestImpl(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl,coord);
}
- public RegionOfInterestImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public RegionOfInterestImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItem.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItem.java
similarity index 82%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItem.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItem.java
index 1f3e5bbb51..84f1b18dad 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SpatialCoordItem.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SpatialCoordItem.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-
import java.util.List;
public abstract class SpatialCoordItem extends MissionItemImpl {
protected LatLongAlt coordinate;
- public SpatialCoordItem(Mission mission, LatLongAlt coord) {
- super(mission);
+ public SpatialCoordItem(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl);
this.coordinate = coord;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SplineWaypointImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SplineWaypointImpl.java
similarity index 71%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SplineWaypointImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SplineWaypointImpl.java
index 289ab46cb0..65bdc7aad8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/SplineWaypointImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/SplineWaypointImpl.java
@@ -1,12 +1,12 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
-import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+import com.o3dr.services.android.lib.coordinate.LatLongAlt;
import java.util.List;
@@ -25,12 +25,12 @@ public SplineWaypointImpl(MissionItemImpl item) {
super(item);
}
- public SplineWaypointImpl(Mission mission, LatLongAlt coord) {
- super(mission, coord);
+ public SplineWaypointImpl(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl, coord);
}
- public SplineWaypointImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public SplineWaypointImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/StructureScannerImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/StructureScannerImpl.java
similarity index 81%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/StructureScannerImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/StructureScannerImpl.java
index 967228f85c..317316c318 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/StructureScannerImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/StructureScannerImpl.java
@@ -1,20 +1,20 @@
-package org.droidplanner.services.android.core.mission.waypoints;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
+import org.droidplanner.services.android.impl.core.mission.survey.SurveyImpl;
+import org.droidplanner.services.android.impl.core.polygon.Polygon;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.core.survey.SurveyData;
+import org.droidplanner.services.android.impl.core.survey.grid.GridBuilder;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
-import org.droidplanner.services.android.core.mission.survey.SurveyImpl;
-import org.droidplanner.services.android.core.polygon.Polygon;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.core.survey.SurveyData;
-import org.droidplanner.services.android.core.survey.grid.GridBuilder;
-
import java.util.ArrayList;
import java.util.List;
@@ -25,8 +25,8 @@ public class StructureScannerImpl extends SpatialCoordItem {
private boolean crossHatch = false;
SurveyData survey = new SurveyData();
- public StructureScannerImpl(Mission mission, LatLongAlt coord) {
- super(mission, coord);
+ public StructureScannerImpl(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl, coord);
}
public StructureScannerImpl(MissionItemImpl item) {
@@ -45,13 +45,13 @@ public List packMissionItem() {
}
private void packROI(List list) {
- RegionOfInterestImpl roi = new RegionOfInterestImpl(mission, new LatLongAlt(coordinate, (0.0)));
+ RegionOfInterestImpl roi = new RegionOfInterestImpl(missionImpl, new LatLongAlt(coordinate, (0.0)));
list.addAll(roi.packMissionItem());
}
private void packCircles(List list) {
for (double altitude = coordinate.getAltitude(); altitude <= getTopHeight(); altitude += heightStep) {
- CircleImpl circleImpl = new CircleImpl(mission, new LatLongAlt(coordinate, (altitude)));
+ CircleImpl circleImpl = new CircleImpl(missionImpl, new LatLongAlt(coordinate, (altitude)));
circleImpl.setRadius(radius);
list.addAll(circleImpl.packMissionItem());
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/WaypointImpl.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImpl.java
similarity index 80%
rename from ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/WaypointImpl.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImpl.java
index 17bcc4c9e5..e87fff465c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/mission/waypoints/WaypointImpl.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/mission/waypoints/WaypointImpl.java
@@ -1,15 +1,15 @@
-package org.droidplanner.services.android.core.mission.waypoints;
-
-import java.util.List;
-
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.MissionItemType;
+package org.droidplanner.services.android.impl.core.mission.waypoints;
import com.MAVLink.common.msg_mission_item;
import com.MAVLink.enums.MAV_CMD;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemType;
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
+import java.util.List;
+
public class WaypointImpl extends SpatialCoordItem {
private double delay;
@@ -22,12 +22,12 @@ public WaypointImpl(MissionItemImpl item) {
super(item);
}
- public WaypointImpl(Mission mission, LatLongAlt coord) {
- super(mission, coord);
+ public WaypointImpl(MissionImpl missionImpl, LatLongAlt coord) {
+ super(missionImpl, coord);
}
- public WaypointImpl(msg_mission_item msg, Mission mission) {
- super(mission, null);
+ public WaypointImpl(msg_mission_item msg, MissionImpl missionImpl) {
+ super(missionImpl, null);
unpackMAVMessage(msg);
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/model/AutopilotWarningParser.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/AutopilotWarningParser.java
similarity index 58%
rename from ServiceApp/src/org/droidplanner/services/android/core/model/AutopilotWarningParser.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/AutopilotWarningParser.java
index cdb6a69275..1a6a5208be 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/model/AutopilotWarningParser.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/AutopilotWarningParser.java
@@ -1,6 +1,6 @@
-package org.droidplanner.services.android.core.model;
+package org.droidplanner.services.android.impl.core.model;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
/**
* Parse received autopilot warning messages.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/model/Logger.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/Logger.java
similarity index 91%
rename from ServiceApp/src/org/droidplanner/services/android/core/model/Logger.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/Logger.java
index d141af3af5..4d582ef4f7 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/model/Logger.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/model/Logger.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.model;
+package org.droidplanner.services.android.impl.core.model;
/**
* Defines a set of essential logging utilities.
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/polygon/Polygon.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/polygon/Polygon.java
similarity index 83%
rename from ServiceApp/src/org/droidplanner/services/android/core/polygon/Polygon.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/polygon/Polygon.java
index fd5ff4f6a5..aaf7cb6b6a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/polygon/Polygon.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/polygon/Polygon.java
@@ -1,15 +1,14 @@
-package org.droidplanner.services.android.core.polygon;
+package org.droidplanner.services.android.impl.core.polygon;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineLatLong;
+import org.droidplanner.services.android.impl.core.helpers.units.Area;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.helpers.geoTools.LineLatLong;
-import org.droidplanner.services.android.core.helpers.units.Area;
-
public class Polygon {
private List points = new ArrayList();
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/srtm/Srtm.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/Srtm.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/srtm/Srtm.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/Srtm.java
index 03913c7b85..f5e177e8bb 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/srtm/Srtm.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/Srtm.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.srtm;
+package org.droidplanner.services.android.impl.core.srtm;
public class Srtm {
private static final int SRTM_NaN = -32768;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmData.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmData.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmData.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmData.java
index d5b7f2fac2..15da9f6559 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmData.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmData.java
@@ -1,4 +1,6 @@
-package org.droidplanner.services.android.core.srtm;
+package org.droidplanner.services.android.impl.core.srtm;
+
+import org.droidplanner.services.android.impl.core.srtm.Srtm.OnProgressListner;
import java.io.BufferedInputStream;
import java.io.File;
@@ -6,8 +8,6 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.droidplanner.services.android.core.srtm.Srtm.OnProgressListner;
-
public class SrtmData {
private String path;
private File srtmFile;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmDownloader.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmDownloader.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmDownloader.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmDownloader.java
index aa534bcaad..8049c50c81 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmDownloader.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmDownloader.java
@@ -1,4 +1,6 @@
-package org.droidplanner.services.android.core.srtm;
+package org.droidplanner.services.android.impl.core.srtm;
+
+import org.droidplanner.services.android.impl.core.srtm.Srtm.OnProgressListner;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -9,8 +11,6 @@
import java.net.URL;
import java.net.URLConnection;
-import org.droidplanner.services.android.core.srtm.Srtm.OnProgressListner;
-
public class SrtmDownloader {
static final String url = "http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/";
private OnProgressListner listner;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmRegions.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmRegions.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmRegions.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmRegions.java
index a0e466857a..ff3bada3ec 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/srtm/SrtmRegions.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/SrtmRegions.java
@@ -1,4 +1,6 @@
-package org.droidplanner.services.android.core.srtm;
+package org.droidplanner.services.android.impl.core.srtm;
+
+import org.droidplanner.services.android.impl.core.srtm.Srtm.OnProgressListner;
import java.io.File;
import java.io.IOException;
@@ -6,8 +8,6 @@
import java.util.Map;
import java.util.Scanner;
-import org.droidplanner.services.android.core.srtm.Srtm.OnProgressListner;
-
public class SrtmRegions {
static final String[] REGIONS = { "Eurasia", "Africa", "Australia", "Islands", "North_America",
"South_America" };
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/srtm/UnZip.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/UnZip.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/core/srtm/UnZip.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/UnZip.java
index aba889bccf..bf96582e72 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/srtm/UnZip.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/srtm/UnZip.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.srtm;
+package org.droidplanner.services.android.impl.core.srtm;
import java.io.File;
import java.io.FileOutputStream;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/CameraInfo.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/CameraInfo.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/CameraInfo.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/CameraInfo.java
index da679f11a4..897d875062 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/CameraInfo.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/CameraInfo.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.core.survey;
+package org.droidplanner.services.android.impl.core.survey;
public class CameraInfo {
public String name = "Canon SX260";
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/Footprint.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/Footprint.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/Footprint.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/Footprint.java
index 43f356453c..16cabb4af8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/Footprint.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/Footprint.java
@@ -1,11 +1,11 @@
-package org.droidplanner.services.android.core.survey;
+package org.droidplanner.services.android.impl.core.survey;
import com.MAVLink.ardupilotmega.msg_camera_feedback;
+
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.util.MathUtils;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-
import java.util.ArrayList;
import java.util.List;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/SurveyData.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/SurveyData.java
similarity index 95%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/SurveyData.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/SurveyData.java
index 9d3643bff3..90603bd550 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/SurveyData.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/SurveyData.java
@@ -1,6 +1,6 @@
-package org.droidplanner.services.android.core.survey;
+package org.droidplanner.services.android.impl.core.survey;
-import org.droidplanner.services.android.core.helpers.units.Area;
+import org.droidplanner.services.android.impl.core.helpers.units.Area;
import java.util.Locale;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/CircumscribedGrid.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/CircumscribedGrid.java
similarity index 83%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/grid/CircumscribedGrid.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/CircumscribedGrid.java
index 238e0aedcc..f25b3a3595 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/CircumscribedGrid.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/CircumscribedGrid.java
@@ -1,14 +1,13 @@
-package org.droidplanner.services.android.core.survey.grid;
+package org.droidplanner.services.android.impl.core.survey.grid;
+import org.droidplanner.services.android.impl.core.helpers.coordinates.CoordBounds;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.GeoTools;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineLatLong;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.ArrayList;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.coordinates.CoordBounds;
-import org.droidplanner.services.android.core.helpers.geoTools.GeoTools;
-import org.droidplanner.services.android.core.helpers.geoTools.LineLatLong;
-
public class CircumscribedGrid {
private static final int MAX_NUMBER_OF_LINES = 300;
List grid = new ArrayList();
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/EndpointSorter.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/EndpointSorter.java
similarity index 86%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/grid/EndpointSorter.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/EndpointSorter.java
index 453893acd0..91bd0fee8b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/EndpointSorter.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/EndpointSorter.java
@@ -1,14 +1,13 @@
-package org.droidplanner.services.android.core.survey.grid;
+package org.droidplanner.services.android.impl.core.survey.grid;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineLatLong;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineSampler;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.ArrayList;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.geoTools.LineLatLong;
-import org.droidplanner.services.android.core.helpers.geoTools.LineSampler;
-import org.droidplanner.services.android.core.helpers.geoTools.LineTools;
-
public class EndpointSorter {
private static final int MAX_NUMBER_OF_CAMERAS = 2000;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Grid.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Grid.java
similarity index 82%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Grid.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Grid.java
index 22ee63c62e..42f80bfb6e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Grid.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Grid.java
@@ -1,9 +1,8 @@
-package org.droidplanner.services.android.core.survey.grid;
+package org.droidplanner.services.android.impl.core.survey.grid;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.PolylineTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
-import org.droidplanner.services.android.core.helpers.geoTools.PolylineTools;
-
import java.util.List;
public class Grid {
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/GridBuilder.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/GridBuilder.java
similarity index 83%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/grid/GridBuilder.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/GridBuilder.java
index 7a3f8e7d37..25a2560318 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/GridBuilder.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/GridBuilder.java
@@ -1,13 +1,12 @@
-package org.droidplanner.services.android.core.survey.grid;
+package org.droidplanner.services.android.impl.core.survey.grid;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineLatLong;
+import org.droidplanner.services.android.impl.core.polygon.Polygon;
+import org.droidplanner.services.android.impl.core.survey.SurveyData;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.geoTools.LineLatLong;
-import org.droidplanner.services.android.core.polygon.Polygon;
-import org.droidplanner.services.android.core.survey.SurveyData;
-
public class GridBuilder {
private Polygon poly;
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Trimmer.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Trimmer.java
similarity index 84%
rename from ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Trimmer.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Trimmer.java
index 816a15d94e..7544681b1f 100644
--- a/ServiceApp/src/org/droidplanner/services/android/core/survey/grid/Trimmer.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/core/survey/grid/Trimmer.java
@@ -1,13 +1,12 @@
-package org.droidplanner.services.android.core.survey.grid;
+package org.droidplanner.services.android.impl.core.survey.grid;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineLatLong;
+import org.droidplanner.services.android.impl.core.helpers.geoTools.LineTools;
import com.o3dr.services.android.lib.coordinate.LatLong;
import java.util.ArrayList;
import java.util.List;
-import org.droidplanner.services.android.core.helpers.geoTools.LineLatLong;
-import org.droidplanner.services.android.core.helpers.geoTools.LineTools;
-
public class Trimmer {
List trimedGrid = new ArrayList();
diff --git a/ServiceApp/src/org/droidplanner/services/android/exception/ConnectionException.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/exception/ConnectionException.java
similarity index 73%
rename from ServiceApp/src/org/droidplanner/services/android/exception/ConnectionException.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/exception/ConnectionException.java
index 879e997aab..7da22d062d 100644
--- a/ServiceApp/src/org/droidplanner/services/android/exception/ConnectionException.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/exception/ConnectionException.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.exception;
+package org.droidplanner.services.android.impl.exception;
/**
* Created by fhuya on 11/2/14.
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/ui/activity/UsbIntentReceiver.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/ui/activity/UsbIntentReceiver.java
new file mode 100644
index 0000000000..d2ad541aa6
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/ui/activity/UsbIntentReceiver.java
@@ -0,0 +1,36 @@
+package org.droidplanner.services.android.impl.ui.activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+
+/**
+ * Created by fhuya on 11/12/14.
+ */
+public class UsbIntentReceiver extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState){
+ super.onCreate(savedInstanceState);
+ TextView contentView = new TextView(getApplicationContext());
+ contentView.setText("Accessing USB Device...");
+ contentView.setGravity(Gravity.CENTER);
+ setContentView(contentView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
+ handleIntent(getIntent());
+ }
+
+ @Override
+ public void onNewIntent(Intent intent){
+ super.onNewIntent(intent);
+ handleIntent(intent);
+ }
+
+ private void handleIntent(Intent intent) {
+ finish();
+ }
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/AndroidApWarningParser.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidApWarningParser.java
similarity index 96%
rename from ServiceApp/src/org/droidplanner/services/android/utils/AndroidApWarningParser.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidApWarningParser.java
index 49bc607c39..7503d8dd5e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/AndroidApWarningParser.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidApWarningParser.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
import com.o3dr.services.android.lib.drone.attribute.error.ErrorType;
-import org.droidplanner.services.android.core.model.AutopilotWarningParser;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.model.AutopilotWarningParser;
import java.util.Locale;
@@ -60,10 +60,10 @@ public String getDefaultWarning() {
}
/**
- * Maps the ArduPilot warnings set to the 3DR Services warnings set.
+ * Maps the ArduPilot warnings set to the DroneKit-Android warnings set.
*
* @param warning warning originating from the ArduPilot autopilot
- * @return equivalent 3DR Services warning type
+ * @return equivalent DroneKit-Android warning type
*/
@Override
public String parseWarning(MavLinkDrone drone, String warning) {
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/AndroidLogger.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidLogger.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/utils/AndroidLogger.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidLogger.java
index 00d228fba2..a511c69e60 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/AndroidLogger.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/AndroidLogger.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.utils;
-
-import org.droidplanner.services.android.core.model.Logger;
+package org.droidplanner.services.android.impl.utils;
import android.util.Log;
+import org.droidplanner.services.android.impl.core.model.Logger;
+
/**
* Android specific implementation for the {org.droidplanner.services.android.core.model.Logger}
* interface.
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/CommonApiUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/CommonApiUtils.java
similarity index 92%
rename from ServiceApp/src/org/droidplanner/services/android/utils/CommonApiUtils.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/CommonApiUtils.java
index 2b6ffd3442..b5e76b05c8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/CommonApiUtils.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/CommonApiUtils.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
import android.os.Bundle;
import android.os.RemoteException;
@@ -41,26 +41,27 @@
import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.MAVLink.MavLinkCommands;
-import org.droidplanner.services.android.core.MAVLink.command.doCmd.MavLinkDoCmds;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.ArduPilot;
-import org.droidplanner.services.android.core.drone.autopilot.generic.GenericMavLinkDrone;
-import org.droidplanner.services.android.core.drone.profiles.ParameterManager;
-import org.droidplanner.services.android.core.drone.variables.ApmModes;
-import org.droidplanner.services.android.core.drone.variables.Camera;
-import org.droidplanner.services.android.core.drone.variables.GuidedPoint;
-import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.gcs.follow.Follow;
-import org.droidplanner.services.android.core.gcs.follow.FollowAlgorithm;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.survey.SplineSurveyImpl;
-import org.droidplanner.services.android.core.mission.survey.SurveyImpl;
-import org.droidplanner.services.android.core.mission.waypoints.StructureScannerImpl;
-import org.droidplanner.services.android.core.survey.Footprint;
+import org.droidplanner.services.android.impl.core.MAVLink.MavLinkCommands;
+import org.droidplanner.services.android.impl.core.MAVLink.command.doCmd.MavLinkDoCmds;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.MavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.ArduPilot;
+import org.droidplanner.services.android.impl.core.drone.autopilot.generic.GenericMavLinkDrone;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterManager;
+import org.droidplanner.services.android.impl.core.drone.variables.ApmModes;
+import org.droidplanner.services.android.impl.core.drone.variables.Camera;
+import org.droidplanner.services.android.impl.core.drone.variables.GuidedPoint;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.AccelCalibration;
+import org.droidplanner.services.android.impl.core.drone.variables.calibration.MagnetometerCalibrationImpl;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.core.gcs.follow.Follow;
+import org.droidplanner.services.android.impl.core.gcs.follow.FollowAlgorithm;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SplineSurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.StructureScannerImpl;
+import org.droidplanner.services.android.impl.core.survey.Footprint;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -377,7 +378,7 @@ public static State getState(MavLinkDrone drone, boolean isConnected, Vibration
if (drone == null)
return new State();
- org.droidplanner.services.android.core.drone.variables.State droneState = drone.getState();
+ org.droidplanner.services.android.impl.core.drone.variables.State droneState = drone.getState();
ApmModes droneMode = droneState.getMode();
AccelCalibration accelCalibration = drone.getCalibrationSetup();
String calibrationMessage = accelCalibration != null && accelCalibration.isCalibrating()
@@ -407,8 +408,8 @@ public static Mission getMission(MavLinkDrone drone) {
if (drone == null)
return proxyMission;
- org.droidplanner.services.android.core.mission.Mission droneMission = drone.getMission();
- List droneMissionItemImpls = droneMission.getComponentItems();
+ MissionImpl droneMissionImpl = drone.getMission();
+ List droneMissionItemImpls = droneMissionImpl.getComponentItems();
proxyMission.setCurrentMissionItem((short) drone.getMissionStats().getCurrentWP());
@@ -584,16 +585,16 @@ public static void setMission(MavLinkDrone drone, Mission mission, boolean pushT
if (drone == null)
return;
- org.droidplanner.services.android.core.mission.Mission droneMission = drone.getMission();
- droneMission.clearMissionItems();
+ MissionImpl droneMissionImpl = drone.getMission();
+ droneMissionImpl.clearMissionItems();
List itemsList = mission.getMissionItems();
for (MissionItem item : itemsList) {
- droneMission.addMissionItem(ProxyUtils.getMissionItemImpl(droneMission, item));
+ droneMissionImpl.addMissionItem(ProxyUtils.getMissionItemImpl(droneMissionImpl, item));
}
if (pushToDrone)
- droneMission.sendMissionToAPM();
+ droneMissionImpl.sendMissionToAPM();
}
public static void startMission(final ArduPilot drone, final boolean forceModeChange, boolean forceArm, final ICommandListener listener) {
@@ -682,7 +683,7 @@ public static void arm(final ArduPilot drone, final boolean arm, final boolean e
return;
if (!arm && emergencyDisarm) {
- if (org.droidplanner.services.android.core.drone.variables.Type.isCopter(drone.getType()) && !isKillSwitchSupported(drone)) {
+ if (org.droidplanner.services.android.impl.core.drone.variables.Type.isCopter(drone.getType()) && !isKillSwitchSupported(drone)) {
changeVehicleMode(drone, VehicleMode.COPTER_STABILIZE, new AbstractCommandListener() {
@Override
@@ -730,7 +731,7 @@ public static boolean isKillSwitchSupported(MavLinkDrone drone) {
if (drone == null)
return false;
- if (!org.droidplanner.services.android.core.drone.variables.Type.isCopter(drone.getType()))
+ if (!org.droidplanner.services.android.impl.core.drone.variables.Type.isCopter(drone.getType()))
return false;
String firmwareVersion = drone.getFirmwareVersion();
@@ -904,25 +905,25 @@ public static void buildComplexMissionItem(MavLinkDrone drone, Bundle itemBundle
}
public static Survey buildSurvey(MavLinkDrone drone, Survey survey) {
- org.droidplanner.services.android.core.mission.Mission droneMission = drone == null ? null : drone.getMission();
+ MissionImpl droneMissionImpl = drone == null ? null : drone.getMission();
SurveyImpl updatedSurveyImpl = (SurveyImpl) ProxyUtils.getMissionItemImpl
- (droneMission, survey);
+ (droneMissionImpl, survey);
return (Survey) ProxyUtils.getProxyMissionItem(updatedSurveyImpl);
}
public static Survey buildSplineSurvey(MavLinkDrone drone, Survey survey) {
- org.droidplanner.services.android.core.mission.Mission droneMission = drone == null ? null : drone.getMission();
+ MissionImpl droneMissionImpl = drone == null ? null : drone.getMission();
SplineSurveyImpl updatedSplineSurvey = (SplineSurveyImpl)
- ProxyUtils.getMissionItemImpl(droneMission, survey);
+ ProxyUtils.getMissionItemImpl(droneMissionImpl, survey);
return (Survey) ProxyUtils.getProxyMissionItem(updatedSplineSurvey);
}
public static StructureScanner buildStructureScanner(MavLinkDrone drone, StructureScanner item) {
- org.droidplanner.services.android.core.mission.Mission droneMission = drone == null ? null : drone.getMission();
+ MissionImpl droneMissionImpl = drone == null ? null : drone.getMission();
StructureScannerImpl updatedScan = (StructureScannerImpl) ProxyUtils
- .getMissionItemImpl(droneMission, item);
+ .getMissionItemImpl(droneMissionImpl, item);
StructureScanner proxyScanner = (StructureScanner) ProxyUtils.getProxyMissionItem(updatedScan);
return proxyScanner;
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/MissionUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/MissionUtils.java
new file mode 100644
index 0000000000..d160b98503
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/MissionUtils.java
@@ -0,0 +1,298 @@
+package org.droidplanner.services.android.impl.utils;
+
+import android.content.Context;
+import android.net.Uri;
+
+import com.MAVLink.common.msg_mission_item;
+import com.MAVLink.enums.MAV_CMD;
+import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
+import com.o3dr.services.android.lib.drone.mission.Mission;
+import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
+import com.o3dr.services.android.lib.model.ICommandListener;
+import com.o3dr.services.android.lib.util.ParcelableUtils;
+import com.o3dr.services.android.lib.util.UriUtils;
+
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.CameraTriggerImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ChangeSpeedImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ConditionYawImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.DoJumpImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.EpmGripperImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ReturnToHomeImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetRelayImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetServoImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.TakeoffImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.CircleImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.DoLandStartImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.LandImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.RegionOfInterestImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.SplineWaypointImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.WaypointImpl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import timber.log.Timber;
+
+/**
+ * Created by fhuya on 8/13/2016.
+ */
+public class MissionUtils {
+
+ /**
+ * Waypoint file format:
+ *
+ * * QGC WPL
+ *
+ *
+ *
+ * See http://qgroundcontrol.org/mavlink/waypoint_protocol for details
+ */
+ private static final String WAYPOINT_PROTOCOL_HEADER = "QGC WPL 110";
+
+ private MissionUtils(){}
+
+ public static void saveMission(Context context, Mission mission, Uri saveUri, ICommandListener listener){
+ saveMissionToWPL(context, mission, saveUri, listener);
+ }
+
+ public static Mission loadMission(Context context, Uri loadUri){
+ // Attempt to load the mission using the waypoint file format.
+ Mission mission = loadMissionFromWPL(context, loadUri);
+ if(mission == null){
+ // Attempt to load using the deprecated dpwp formt
+ mission = loadMissionFromDpwp(context, loadUri);
+ }
+ return mission;
+ }
+
+ private static void saveMissionToWPL(Context context, Mission mission, Uri saveUri, ICommandListener listener){
+ try {
+ OutputStream saveOut = UriUtils.getOutputStream(context, saveUri);
+ try {
+ String header = WAYPOINT_PROTOCOL_HEADER + "\n";
+ saveOut.write(header.getBytes());
+
+ // Get the list of msg mission item
+ List rawMissionItems = fromMission(mission);
+ for (int i = 0, msgMissionItemsSize = rawMissionItems.size(); i < msgMissionItemsSize; i++) {
+ final msg_mission_item msg = rawMissionItems.get(i);
+
+ // write msg (TAB delimited)
+ saveOut.write(String.format(Locale.ENGLISH,
+ "%d\t%d\t%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%d\n",
+ i,
+ i == 0 ? 1 : 0, // set CURRENT_WP = 1 for 'home' - msg[0], 0
+ // for all others
+ msg.frame, msg.command, msg.param1, msg.param2, msg.param3, msg.param4, msg.x,
+ msg.y, msg.z, msg.autocontinue).getBytes());
+ }
+
+ CommonApiUtils.postSuccessEvent(listener);
+ }finally{
+ saveOut.close();
+ }
+ } catch (IOException e) {
+ Timber.e(e, "Unable to write to uri %s", saveUri);
+ CommonApiUtils.postErrorEvent(CommandExecutionError.COMMAND_FAILED, listener);
+ }
+ }
+
+ private static void saveMissionToDpwp(Context context, Mission mission, Uri saveUri, ICommandListener listener){
+ try{
+ OutputStream saveOut = UriUtils.getOutputStream(context, saveUri);
+ try{
+ byte[] missionBytes = ParcelableUtils.marshall(mission);
+ saveOut.write(missionBytes);
+ CommonApiUtils.postSuccessEvent(listener);
+ }finally{
+ saveOut.close();
+ }
+
+ } catch(IOException e){
+ Timber.e(e, "Unable to write to uri %s", saveUri);
+ CommonApiUtils.postErrorEvent(CommandExecutionError.COMMAND_FAILED, listener);
+ }
+ }
+
+ private static Mission loadMissionFromDpwp(Context context, Uri loadUri){
+ try{
+ InputStream loadIn = UriUtils.getInputStream(context, loadUri);
+ try{
+ Map bytesList = new LinkedHashMap<>();
+ int length = 0;
+ while(loadIn.available() > 0){
+ byte[] missionBytes = new byte[2048];
+ int bufferSize = loadIn.read(missionBytes);
+ bytesList.put(missionBytes, bufferSize);
+ length += bufferSize;
+ }
+
+ ByteBuffer fullBuffer = ByteBuffer.allocate(length);
+ for(Map.Entry entry : bytesList.entrySet()){
+ fullBuffer.put(entry.getKey(), 0, entry.getValue());
+ }
+
+ Mission mission = ParcelableUtils.unmarshall(fullBuffer.array(), 0, length, Mission.CREATOR);
+ return mission;
+ }finally{
+ loadIn.close();
+ }
+ }catch(IOException e){
+ Timber.e(e, "Unable to read from uri %s", loadUri);
+ return null;
+ }
+ }
+
+ private static Mission loadMissionFromWPL(Context context, Uri loadUri) {
+ try {
+ InputStream loadIn = UriUtils.getInputStream(context, loadUri);
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(loadIn));
+
+ if (!reader.readLine().contains(WAYPOINT_PROTOCOL_HEADER)) {
+ // Invalid file header.
+ Timber.w("Invalid waypoint file format for %s", loadUri);
+ return null;
+ }
+
+ List rawMissionItems = new LinkedList<>();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ // parse line (TAB delimited)
+ final String[] rowData = line.split("\t");
+
+ final msg_mission_item msg = new msg_mission_item();
+ msg.seq = (Short.parseShort(rowData[0]));
+ msg.current = (Byte.parseByte(rowData[1]));
+ msg.frame = (Byte.parseByte(rowData[2]));
+ msg.command = (Short.parseShort(rowData[3]));
+
+ msg.param1 = (Float.parseFloat(rowData[4]));
+ msg.param2 = (Float.parseFloat(rowData[5]));
+ msg.param3 = (Float.parseFloat(rowData[6]));
+ msg.param4 = (Float.parseFloat(rowData[7]));
+
+ msg.x = (Float.parseFloat(rowData[8]));
+ msg.y = (Float.parseFloat(rowData[9]));
+ msg.z = (Float.parseFloat(rowData[10]));
+
+ msg.autocontinue = (Byte.parseByte(rowData[11]));
+
+ rawMissionItems.add(msg);
+ }
+
+ return fromRawMissionItems(rawMissionItems);
+ }finally{
+ loadIn.close();
+ }
+ } catch (IOException e) {
+ Timber.e(e, "Unable to load mission from uri %s", loadUri);
+ return null;
+ }
+ }
+
+ private static List fromMission(Mission mission){
+ if(mission == null)
+ return null;
+
+ List missionItems = mission.getMissionItems();
+ if(missionItems.isEmpty())
+ return Collections.emptyList();
+
+ MissionImpl missionImpl = new MissionImpl(null);
+ List rawMissionItems = new ArrayList<>(missionItems.size());
+ for(MissionItem missionItem : missionItems){
+ MissionItemImpl impl = ProxyUtils.getMissionItemImpl(missionImpl, missionItem);
+ rawMissionItems.addAll(impl.packMissionItem());
+ }
+
+ return rawMissionItems;
+ }
+
+ private static Mission fromRawMissionItems(List rawMissionItems){
+ Mission mission = new Mission();
+ if(rawMissionItems == null || rawMissionItems.isEmpty())
+ return mission;
+
+ List impls = processMavLinkMessages(new MissionImpl(null), rawMissionItems);
+ if(!impls.isEmpty()) {
+ for (MissionItemImpl impl: impls) {
+ MissionItem missionItem = ProxyUtils.getProxyMissionItem(impl);
+ if(missionItem != null){
+ mission.addMissionItem(missionItem);
+ }
+ }
+ }
+ return mission;
+ }
+
+ public static List processMavLinkMessages(MissionImpl missionImpl, List msgs) {
+ List received = new ArrayList();
+ for (msg_mission_item msg : msgs) {
+ switch (msg.command) {
+ case MAV_CMD.MAV_CMD_DO_SET_SERVO:
+ received.add(new SetServoImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_WAYPOINT:
+ received.add(new WaypointImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_SPLINE_WAYPOINT:
+ received.add(new SplineWaypointImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_LAND:
+ received.add(new LandImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_LAND_START:
+ received.add(new DoLandStartImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_TAKEOFF:
+ received.add(new TakeoffImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_CHANGE_SPEED:
+ received.add(new ChangeSpeedImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_SET_CAM_TRIGG_DIST:
+ received.add(new CameraTriggerImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_GRIPPER:
+ received.add(new EpmGripperImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_SET_ROI:
+ received.add(new RegionOfInterestImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_LOITER_TURNS:
+ received.add(new CircleImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_NAV_RETURN_TO_LAUNCH:
+ received.add(new ReturnToHomeImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_CONDITION_YAW:
+ received.add(new ConditionYawImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_SET_RELAY:
+ received.add(new SetRelayImpl(msg, missionImpl));
+ break;
+ case MAV_CMD.MAV_CMD_DO_JUMP:
+ received.add(new DoJumpImpl(msg, missionImpl));
+ break;
+
+ default:
+ break;
+ }
+ }
+ return received;
+ }
+}
diff --git a/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/NetworkUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/NetworkUtils.java
new file mode 100644
index 0000000000..acde99b221
--- /dev/null
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/NetworkUtils.java
@@ -0,0 +1,112 @@
+package org.droidplanner.services.android.impl.utils;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.os.Bundle;
+
+import com.o3dr.android.client.BuildConfig;
+
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnection;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.SoloComp;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.DatagramSocket;
+import java.net.Socket;
+
+import timber.log.Timber;
+
+/**
+ * Created by Fredia Huya-Kouadio on 5/11/15.
+ */
+public class NetworkUtils {
+ /**
+ * Is internet connection available. This method also returns true for the SITL build type
+ * @param context
+ * @return Internet connection availability.
+ */
+ public static boolean isNetworkAvailable(Context context) {
+ if (!BuildConfig.SITL_DEBUG && isOnSololinkNetwork(context))
+ return false;
+
+ ConnectivityManager connectivityManager = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
+ return activeNetworkInfo != null && activeNetworkInfo.isConnected();
+ }
+
+ public static String getCurrentWifiLink(Context context) {
+ final WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+
+ final WifiInfo connectedWifi = wifiMgr.getConnectionInfo();
+ final String connectedSSID = connectedWifi == null ? null : connectedWifi.getSSID().replace("\"", "");
+ return connectedSSID;
+ }
+
+ public static boolean isOnSololinkNetwork(Context context) {
+ if (BuildConfig.SITL_DEBUG)
+ return true;
+
+ final String connectedSSID = getCurrentWifiLink(context);
+ return isSoloNetwork(connectedSSID);
+ }
+
+ public static boolean isSoloNetwork(String ssid) {
+ return ssid != null && ssid.startsWith(SoloComp.SOLO_LINK_WIFI_PREFIX);
+ }
+
+ public static void bindSocketToNetwork(Bundle extras, Socket socket) throws IOException {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ Network network = extras == null
+ ? null
+ : (Network) extras.getParcelable(MavLinkConnection.EXTRA_NETWORK);
+ bindSocketToNetwork(network, socket);
+ }
+ }
+
+ @TargetApi(21)
+ public static void bindSocketToNetwork(Network network, Socket socket) throws IOException {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (network != null && socket != null) {
+ Timber.d("Binding socket to network %s", network);
+ network.bindSocket(socket);
+ }
+ }
+ }
+
+ public static void bindSocketToNetwork(Bundle extras, DatagramSocket socket) throws IOException {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ Network network = extras == null
+ ? null
+ : (Network) extras.getParcelable(MavLinkConnection.EXTRA_NETWORK);
+ bindSocketToNetwork(network, socket);
+ }
+ }
+
+ @TargetApi(21)
+ public static void bindSocketToNetwork(Network network, DatagramSocket socket) throws IOException {
+ if (network != null && socket != null) {
+ Timber.d("Binding datagram socket to network %s", network);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ network.bindSocket(socket);
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ // Can be accessed through reflection.
+ try {
+ Method bindSocketMethod = Network.class.getMethod("bindSocket", DatagramSocket.class);
+ bindSocketMethod.invoke(network, socket);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ Timber.e(e, "Unable to access Network#bindSocket(DatagramSocket).");
+ } catch (InvocationTargetException e) {
+ Timber.e(e, "Unable to invoke Network#bindSocket(DatagramSocket).");
+ }
+ }
+ }
+ }
+}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/ProxyUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/ProxyUtils.java
similarity index 85%
rename from ServiceApp/src/org/droidplanner/services/android/utils/ProxyUtils.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/ProxyUtils.java
index 2261c7c526..568bee34a0 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/ProxyUtils.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/ProxyUtils.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
import android.util.Log;
@@ -15,9 +15,9 @@
import com.o3dr.services.android.lib.drone.mission.item.command.Takeoff;
import com.o3dr.services.android.lib.drone.mission.item.command.YawCondition;
import com.o3dr.services.android.lib.drone.mission.item.complex.CameraDetail;
+import com.o3dr.services.android.lib.drone.mission.item.complex.SplineSurvey;
import com.o3dr.services.android.lib.drone.mission.item.complex.StructureScanner;
import com.o3dr.services.android.lib.drone.mission.item.complex.Survey;
-import com.o3dr.services.android.lib.drone.mission.item.complex.SplineSurvey;
import com.o3dr.services.android.lib.drone.mission.item.complex.SurveyDetail;
import com.o3dr.services.android.lib.drone.mission.item.spatial.Circle;
import com.o3dr.services.android.lib.drone.mission.item.spatial.DoLandStart;
@@ -26,28 +26,28 @@
import com.o3dr.services.android.lib.drone.mission.item.spatial.SplineWaypoint;
import com.o3dr.services.android.lib.drone.mission.item.spatial.Waypoint;
-import org.droidplanner.services.android.core.mission.Mission;
-import org.droidplanner.services.android.core.mission.MissionItemImpl;
-import org.droidplanner.services.android.core.mission.commands.CameraTriggerImpl;
-import org.droidplanner.services.android.core.mission.commands.ChangeSpeedImpl;
-import org.droidplanner.services.android.core.mission.commands.ConditionYawImpl;
-import org.droidplanner.services.android.core.mission.commands.DoJumpImpl;
-import org.droidplanner.services.android.core.mission.commands.EpmGripperImpl;
-import org.droidplanner.services.android.core.mission.commands.ReturnToHomeImpl;
-import org.droidplanner.services.android.core.mission.commands.SetRelayImpl;
-import org.droidplanner.services.android.core.mission.commands.SetServoImpl;
-import org.droidplanner.services.android.core.mission.commands.TakeoffImpl;
-import org.droidplanner.services.android.core.mission.survey.SplineSurveyImpl;
-import org.droidplanner.services.android.core.mission.survey.SurveyImpl;
-import org.droidplanner.services.android.core.mission.waypoints.CircleImpl;
-import org.droidplanner.services.android.core.mission.waypoints.DoLandStartImpl;
-import org.droidplanner.services.android.core.mission.waypoints.LandImpl;
-import org.droidplanner.services.android.core.mission.waypoints.RegionOfInterestImpl;
-import org.droidplanner.services.android.core.mission.waypoints.SplineWaypointImpl;
-import org.droidplanner.services.android.core.mission.waypoints.StructureScannerImpl;
-import org.droidplanner.services.android.core.mission.waypoints.WaypointImpl;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.core.survey.SurveyData;
+import org.droidplanner.services.android.impl.core.mission.MissionImpl;
+import org.droidplanner.services.android.impl.core.mission.MissionItemImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.CameraTriggerImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ChangeSpeedImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ConditionYawImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.DoJumpImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.EpmGripperImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.ReturnToHomeImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetRelayImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.SetServoImpl;
+import org.droidplanner.services.android.impl.core.mission.commands.TakeoffImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SplineSurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.survey.SurveyImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.CircleImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.DoLandStartImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.LandImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.RegionOfInterestImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.SplineWaypointImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.StructureScannerImpl;
+import org.droidplanner.services.android.impl.core.mission.waypoints.WaypointImpl;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.core.survey.SurveyData;
/**
* Created by fhuya on 11/10/14.
@@ -90,7 +90,7 @@ public static SurveyDetail getSurveyDetail(SurveyData surveyData) {
return surveyDetail;
}
- public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem proxyItem) {
+ public static MissionItemImpl getMissionItemImpl(MissionImpl missionImpl, MissionItem proxyItem) {
if (proxyItem == null)
return null;
@@ -100,7 +100,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case CAMERA_TRIGGER: {
CameraTrigger proxy = (CameraTrigger) proxyItem;
- CameraTriggerImpl temp = new CameraTriggerImpl(mission, (proxy.getTriggerDistance()));
+ CameraTriggerImpl temp = new CameraTriggerImpl(missionImpl, (proxy.getTriggerDistance()));
missionItemImpl = temp;
break;
@@ -108,7 +108,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case CHANGE_SPEED: {
ChangeSpeed proxy = (ChangeSpeed) proxyItem;
- ChangeSpeedImpl temp = new ChangeSpeedImpl(mission, proxy.getSpeed());
+ ChangeSpeedImpl temp = new ChangeSpeedImpl(missionImpl, proxy.getSpeed());
missionItemImpl = temp;
break;
@@ -116,7 +116,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case EPM_GRIPPER: {
EpmGripper proxy = (EpmGripper) proxyItem;
- EpmGripperImpl temp = new EpmGripperImpl(mission, proxy.isRelease());
+ EpmGripperImpl temp = new EpmGripperImpl(missionImpl, proxy.isRelease());
missionItemImpl = temp;
break;
@@ -124,7 +124,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case RETURN_TO_LAUNCH: {
ReturnToLaunch proxy = (ReturnToLaunch) proxyItem;
- ReturnToHomeImpl temp = new ReturnToHomeImpl(mission);
+ ReturnToHomeImpl temp = new ReturnToHomeImpl(missionImpl);
temp.setHeight((proxy.getReturnAltitude()));
missionItemImpl = temp;
@@ -133,7 +133,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case SET_SERVO: {
SetServo proxy = (SetServo) proxyItem;
- SetServoImpl temp = new SetServoImpl(mission, proxy.getChannel(), proxy.getPwm());
+ SetServoImpl temp = new SetServoImpl(missionImpl, proxy.getChannel(), proxy.getPwm());
missionItemImpl = temp;
break;
@@ -141,7 +141,8 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case TAKEOFF: {
Takeoff proxy = (Takeoff) proxyItem;
- TakeoffImpl temp = new TakeoffImpl(mission, (proxy.getTakeoffAltitude()));
+ TakeoffImpl temp = new TakeoffImpl(missionImpl, proxy.getTakeoffAltitude(),
+ proxy.getTakeoffPitch());
missionItemImpl = temp;
break;
@@ -149,7 +150,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case CIRCLE: {
Circle proxy = (Circle) proxyItem;
- CircleImpl temp = new CircleImpl(mission, (proxy.getCoordinate()));
+ CircleImpl temp = new CircleImpl(missionImpl, (proxy.getCoordinate()));
temp.setRadius(proxy.getRadius());
temp.setTurns(proxy.getTurns());
@@ -159,7 +160,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case LAND: {
Land proxy = (Land) proxyItem;
- LandImpl temp = new LandImpl(mission, (proxy.getCoordinate()));
+ LandImpl temp = new LandImpl(missionImpl, (proxy.getCoordinate()));
missionItemImpl = temp;
break;
@@ -167,7 +168,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case DO_LAND_START: {
DoLandStart proxy = (DoLandStart) proxyItem;
- DoLandStartImpl temp = new DoLandStartImpl(mission, (proxy.getCoordinate()));
+ DoLandStartImpl temp = new DoLandStartImpl(missionImpl, (proxy.getCoordinate()));
missionItemImpl = temp;
break;
@@ -176,7 +177,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case REGION_OF_INTEREST: {
RegionOfInterest proxy = (RegionOfInterest) proxyItem;
- RegionOfInterestImpl temp = new RegionOfInterestImpl(mission, (proxy.getCoordinate()));
+ RegionOfInterestImpl temp = new RegionOfInterestImpl(missionImpl, (proxy.getCoordinate()));
missionItemImpl = temp;
break;
@@ -184,7 +185,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case RESET_ROI: {
//Sending a roi with all coordinates set to 0 will reset the current roi.
- RegionOfInterestImpl temp = new RegionOfInterestImpl(mission, new LatLongAlt(0, 0, 0));
+ RegionOfInterestImpl temp = new RegionOfInterestImpl(missionImpl, new LatLongAlt(0, 0, 0));
missionItemImpl = temp;
break;
}
@@ -192,7 +193,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case SPLINE_WAYPOINT: {
SplineWaypoint proxy = (SplineWaypoint) proxyItem;
- SplineWaypointImpl temp = new SplineWaypointImpl(mission, (proxy.getCoordinate()));
+ SplineWaypointImpl temp = new SplineWaypointImpl(missionImpl, (proxy.getCoordinate()));
temp.setDelay(proxy.getDelay());
missionItemImpl = temp;
@@ -201,7 +202,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case STRUCTURE_SCANNER: {
StructureScanner proxy = (StructureScanner) proxyItem;
- StructureScannerImpl temp = new StructureScannerImpl(mission, (proxy.getCoordinate()));
+ StructureScannerImpl temp = new StructureScannerImpl(missionImpl, (proxy.getCoordinate()));
temp.setRadius((int) proxy.getRadius());
temp.setNumberOfSteps(proxy.getStepsCount());
temp.setAltitudeStep((int) proxy.getHeightStep());
@@ -217,7 +218,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case WAYPOINT: {
Waypoint proxy = (Waypoint) proxyItem;
- WaypointImpl temp = new WaypointImpl(mission, (proxy
+ WaypointImpl temp = new WaypointImpl(missionImpl, (proxy
.getCoordinate()));
temp.setAcceptanceRadius(proxy.getAcceptanceRadius());
temp.setDelay(proxy.getDelay());
@@ -232,7 +233,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
Survey proxy = (Survey) proxyItem;
SurveyDetail surveyDetail = proxy.getSurveyDetail();
- SurveyImpl temp = new SurveyImpl(mission, proxy.getPolygonPoints());
+ SurveyImpl temp = new SurveyImpl(missionImpl, proxy.getPolygonPoints());
temp.setStartCameraBeforeFirstWaypoint(proxy.isStartCameraBeforeFirstWaypoint());
if (surveyDetail != null) {
@@ -257,7 +258,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
SplineSurvey proxy = (SplineSurvey) proxyItem;
SurveyDetail surveyDetail = proxy.getSurveyDetail();
- SplineSurveyImpl temp = new SplineSurveyImpl(mission, proxy.getPolygonPoints());
+ SplineSurveyImpl temp = new SplineSurveyImpl(missionImpl, proxy.getPolygonPoints());
temp.setStartCameraBeforeFirstWaypoint(proxy.isStartCameraBeforeFirstWaypoint());
if (surveyDetail != null) {
@@ -281,7 +282,7 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case YAW_CONDITION: {
YawCondition proxy = (YawCondition) proxyItem;
- ConditionYawImpl temp = new ConditionYawImpl(mission, proxy.getAngle(), proxy.isRelative());
+ ConditionYawImpl temp = new ConditionYawImpl(missionImpl, proxy.getAngle(), proxy.isRelative());
temp.setAngularSpeed(proxy.getAngularSpeed());
missionItemImpl = temp;
@@ -290,13 +291,13 @@ public static MissionItemImpl getMissionItemImpl(Mission mission, MissionItem pr
case SET_RELAY: {
SetRelay proxy = (SetRelay) proxyItem;
- missionItemImpl = new SetRelayImpl(mission, proxy.getRelayNumber(), proxy.isEnabled());
+ missionItemImpl = new SetRelayImpl(missionImpl, proxy.getRelayNumber(), proxy.isEnabled());
break;
}
case DO_JUMP: {
DoJump proxy = (DoJump) proxyItem;
- missionItemImpl = new DoJumpImpl(mission, proxy.getWaypoint(), proxy.getRepeatCount());
+ missionItemImpl = new DoJumpImpl(missionImpl, proxy.getWaypoint(), proxy.getRepeatCount());
break;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/SoloApiUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/SoloApiUtils.java
similarity index 93%
rename from ServiceApp/src/org/droidplanner/services/android/utils/SoloApiUtils.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/SoloApiUtils.java
index cb057b248d..40de5d3cb8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/SoloApiUtils.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/SoloApiUtils.java
@@ -1,20 +1,19 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
import android.os.RemoteException;
import android.util.Pair;
+import org.droidplanner.services.android.impl.core.drone.autopilot.Drone;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.ArduSolo;
+import org.droidplanner.services.android.impl.core.drone.autopilot.apm.solo.SoloComp;
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
-import com.o3dr.services.android.lib.drone.companion.solo.controller.SoloControllerMode;
import com.o3dr.services.android.lib.drone.companion.solo.SoloState;
+import com.o3dr.services.android.lib.drone.companion.solo.controller.SoloControllerMode;
import com.o3dr.services.android.lib.drone.companion.solo.controller.SoloControllerUnits;
import com.o3dr.services.android.lib.drone.companion.solo.tlv.SoloButtonSettingSetter;
import com.o3dr.services.android.lib.drone.companion.solo.tlv.TLVPacket;
import com.o3dr.services.android.lib.model.ICommandListener;
-import org.droidplanner.services.android.core.drone.autopilot.Drone;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.ArduSolo;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.SoloComp;
-
import timber.log.Timber;
/**
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/TextUtils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/TextUtils.java
similarity index 98%
rename from ServiceApp/src/org/droidplanner/services/android/utils/TextUtils.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/TextUtils.java
index f11a39405a..0f4bee47d3 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/TextUtils.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/TextUtils.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
import android.graphics.Typeface;
import android.text.Spannable;
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/Utils.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/Utils.java
similarity index 77%
rename from ServiceApp/src/org/droidplanner/services/android/utils/Utils.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/Utils.java
index ca8641db86..bd0802dcb8 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/Utils.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/Utils.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils;
+package org.droidplanner.services.android.impl.utils;
/**
* Created by Fredia Huya-Kouadio on 2/4/15.
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/connection/SshConnection.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/SshConnection.java
similarity index 85%
rename from ServiceApp/src/org/droidplanner/services/android/utils/connection/SshConnection.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/SshConnection.java
index a8f232b251..a18435d1e2 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/connection/SshConnection.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/SshConnection.java
@@ -1,5 +1,8 @@
-package org.droidplanner.services.android.utils.connection;
+package org.droidplanner.services.android.impl.utils.connection;
+import android.net.Network;
+import android.os.Build;
+import android.os.Bundle;
import android.text.TextUtils;
import com.jcraft.jsch.Channel;
@@ -7,6 +10,10 @@
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
+import com.jcraft.jsch.SocketFactory;
+
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnection;
import java.io.File;
import java.io.FileInputStream;
@@ -14,6 +21,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.Socket;
+import java.net.UnknownHostException;
import timber.log.Timber;
@@ -45,18 +54,28 @@ public interface DownloadListener {
private final String host;
private final String username;
private final String password;
+ private final DataLink.DataLinkProvider linkProvider;
- public SshConnection(String host, String username, String password) {
+ public SshConnection(String host, String username, String password, DataLink.DataLinkProvider linkProvider) {
this.jsch = new JSch();
this.host = host;
this.username = username;
this.password = password;
+ this.linkProvider = linkProvider;
}
private Session getSession() throws JSchException {
Session session = jsch.getSession(username, host);
- //Try to connect with the password set.
+ Bundle extras = linkProvider.getConnectionExtras();
+ if (extras != null && !extras.isEmpty()) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ Network network = extras.getParcelable(MavLinkConnection.EXTRA_NETWORK);
+ if (network != null) {
+ session.setSocketFactory(new SshSocketFactory(network.getSocketFactory()));
+ }
+ }
+ }
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(this.password);
session.connect(CONNECTION_TIMEOUT);
@@ -367,4 +386,28 @@ private static int checkAck(InputStream in) throws IOException {
return result;
}
+
+ private static class SshSocketFactory implements SocketFactory {
+
+ private final javax.net.SocketFactory socketFactory;
+
+ private SshSocketFactory(javax.net.SocketFactory socketFactory) {
+ this.socketFactory = socketFactory;
+ }
+
+ @Override
+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
+ return socketFactory.createSocket(host, port);
+ }
+
+ @Override
+ public InputStream getInputStream(Socket socket) throws IOException {
+ return socket.getInputStream();
+ }
+
+ @Override
+ public OutputStream getOutputStream(Socket socket) throws IOException {
+ return socket.getOutputStream();
+ }
+ }
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/connection/WifiConnectionHandler.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/WifiConnectionHandler.java
similarity index 79%
rename from ServiceApp/src/org/droidplanner/services/android/utils/connection/WifiConnectionHandler.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/WifiConnectionHandler.java
index c1488398a5..12f2bdcb36 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/connection/WifiConnectionHandler.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/connection/WifiConnectionHandler.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils.connection;
+package org.droidplanner.services.android.impl.utils.connection;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
@@ -18,12 +18,14 @@
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
+import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;
import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
-import org.droidplanner.services.android.utils.NetworkUtils;
+import org.droidplanner.services.android.impl.core.MAVLink.connection.MavLinkConnection;
+import org.droidplanner.services.android.impl.utils.NetworkUtils;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -35,8 +37,12 @@
*/
public class WifiConnectionHandler {
+ public static final String EXTRA_SSID = "extra_ssid";
+ public static final String EXTRA_SSID_PASSWORD = "extra_ssid_password";
+ public static final String EXTRA_SCAN_RESULT = "extra_scan_result";
+
public interface WifiConnectionListener {
- void onWifiConnected(String wifiSsid);
+ void onWifiConnected(String wifiSsid, Bundle extras);
void onWifiConnecting();
@@ -105,7 +111,7 @@ public void onReceive(Context context, Intent intent) {
}
if (wifiSSID != null) {
- setDefaultNetworkIfNecessary(wifiSSID);
+ updateNetworkIfNecessary(wifiSSID, null);
}
break;
@@ -119,7 +125,7 @@ public void onReceive(Context context, Intent intent) {
NetworkInfo.DetailedState detailedState = netInfo.getDetailedState();
if (detailedState != null && detailedState == NetworkInfo.DetailedState.VERIFYING_POOR_LINK) {
String connectingSsid = NetworkUtils.getCurrentWifiLink(context);
- setDefaultNetworkIfNecessary(connectingSsid);
+ updateNetworkIfNecessary(connectingSsid, null);
}
}
Timber.d("Connecting to wifi network.");
@@ -180,26 +186,20 @@ public void onAvailable(Network network) {
//Check if we're still connected to solo. If not, unregister the callbacks
final String currentWifi = getCurrentWifiLink();
if (!isSoloWifi(currentWifi)) {
- resetNetworkBindings(this);
+ try {
+ connMgr.unregisterNetworkCallback(this);
+ } catch (IllegalArgumentException e) {
+ Timber.w(e, "Network callback was not registered.");
+ }
return;
}
Timber.i("Network %s is available", network);
getNetworkInfo(network);
- final boolean wasBound;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- wasBound = connMgr.bindProcessToNetwork(network);
- } else {
- wasBound = ConnectivityManager.setProcessDefaultNetwork(network);
- }
-
- if (wasBound) {
- Timber.i("Bound process to network %s", network);
- notifyWifiConnected(currentWifi);
- } else {
- Timber.w("Unable to bind process to network %s", network);
- }
+ Bundle extras = new Bundle(1);
+ extras.putParcelable(MavLinkConnection.EXTRA_NETWORK, network);
+ notifyWifiConnected(currentWifi, extras);
}
@Override
@@ -242,25 +242,11 @@ public void stop() {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- resetNetworkBindings((ConnectivityManager.NetworkCallback) netReqCb);
- }
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void resetNetworkBindings(ConnectivityManager.NetworkCallback netCb) {
- Timber.i("Unregistering network callbacks.");
-
- connectedWifi.set(NetworkUtils.getCurrentWifiLink(context));
- try {
- connMgr.unregisterNetworkCallback(netCb);
- } catch (IllegalArgumentException e) {
- Timber.w(e, "Network callback was not registered.");
- }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- connMgr.bindProcessToNetwork(null);
- } else {
- ConnectivityManager.setProcessDefaultNetwork(null);
+ try {
+ connMgr.unregisterNetworkCallback((ConnectivityManager.NetworkCallback) netReqCb);
+ } catch (IllegalArgumentException e) {
+ Timber.w(e, "Network callback was not registered.");
+ }
}
}
@@ -289,19 +275,15 @@ public boolean isOnNetwork(String wifiSsid) {
return wifiSsid.equalsIgnoreCase(getCurrentWifiLink());
}
- public boolean isConnected(String wifiSSID) {
+ public boolean isConnected(String wifiSSID, Bundle info) {
if (!isOnNetwork(wifiSSID)) {
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- Network network;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- network = connMgr.getBoundNetworkForProcess();
- } else {
- network = ConnectivityManager.getProcessDefaultNetwork();
- }
-
+ Network network = info == null
+ ? null
+ : (Network) info.getParcelable(MavLinkConnection.EXTRA_NETWORK);
if (network == null) {
return false;
}
@@ -317,52 +299,58 @@ public List getScanResults() {
return wifiMgr.getScanResults();
}
- public int connectToWifi(String soloLinkId, String password) {
- if (TextUtils.isEmpty(soloLinkId)) {
- return LinkConnectionStatus.INVALID_CREDENTIALS;
+ private ScanResult getScanResult(String ssid) {
+ if (TextUtils.isEmpty(ssid)) {
+ return null;
}
-
- ScanResult targetScanResult = null;
final List scanResults = wifiMgr.getScanResults();
for (ScanResult result : scanResults) {
- if (result.SSID.equalsIgnoreCase(soloLinkId)) {
- targetScanResult = result;
- break;
+ if (result.SSID.equalsIgnoreCase(ssid)) {
+ return result;
}
}
+ return null;
+ }
- if (targetScanResult == null) {
- Timber.i("No matching scan result was found for id %s", soloLinkId);
- return LinkConnectionStatus.LINK_UNAVAILABLE;
+ public int connectToWifi(Bundle info) {
+ if (info == null || info.isEmpty()) {
+ return LinkConnectionStatus.INVALID_CREDENTIALS;
}
- return connectToWifi(targetScanResult, password);
- }
-
- public int connectToWifi(ScanResult scanResult, String password) {
+ ScanResult scanResult = info.getParcelable(EXTRA_SCAN_RESULT);
if (scanResult == null) {
- return LinkConnectionStatus.LINK_UNAVAILABLE;
+ // Check if the ssid was given.
+ String ssid = info.getString(EXTRA_SSID);
+ if (TextUtils.isEmpty(ssid)) {
+ return LinkConnectionStatus.INVALID_CREDENTIALS;
+ }
+
+ // Get the scan result that match the given ssid.
+ scanResult = getScanResult(ssid);
+ if (scanResult == null) {
+ Timber.i("No matching scan result was found for id %s", ssid);
+ return LinkConnectionStatus.LINK_UNAVAILABLE;
+ }
}
Timber.d("Connecting to wifi " + scanResult.SSID);
-
//Check if we're already connected to the given network.
- if (isConnected(scanResult.SSID)) {
+ if (isConnected(scanResult.SSID, info)) {
Timber.d("Already connected to " + scanResult.SSID);
- notifyWifiConnected(scanResult.SSID);
+ notifyWifiConnected(scanResult.SSID, info);
return 0;
} else if (isOnNetwork(scanResult.SSID)) {
- setDefaultNetworkIfNecessary(scanResult.SSID);
+ updateNetworkIfNecessary(scanResult.SSID, info);
return 0;
-
}
WifiConfiguration wifiConfig = getWifiConfigs(scanResult.SSID);
//Network is not configured and needs a password to connect
if (wifiConfig == null) {
+ String password = info.getString(EXTRA_SSID_PASSWORD);
Timber.d("Connecting to closed wifi network.");
if (TextUtils.isEmpty(password)) {
return LinkConnectionStatus.INVALID_CREDENTIALS;
@@ -434,35 +422,30 @@ public static boolean isSoloWifi(String wifiSsid) {
return !TextUtils.isEmpty(wifiSsid) && wifiSsid.startsWith(SOLO_LINK_WIFI_PREFIX);
}
- private void setDefaultNetworkIfNecessary(String wifiSsid) {
+ private void updateNetworkIfNecessary(String wifiSsid, Bundle info) {
final String trimmedSsid = trimWifiSsid(wifiSsid);
- if (!trimmedSsid.equals(connectedWifi.get())) {
- connectedWifi.set(trimmedSsid);
-
- if (isConnected(wifiSsid)) {
- notifyWifiConnected(wifiSsid);
- return;
- }
-
- if (isSoloWifi(trimmedSsid)) {
- //Attempt to connect to the vehicle.
- Timber.i("Requesting route to sololink network");
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- connMgr.requestNetwork((NetworkRequest) netReq, (ConnectivityManager.NetworkCallback) netReqCb);
- } else {
- notifyWifiConnected(trimmedSsid);
+ if (isConnected(wifiSsid, info)) {
+ notifyWifiConnected(wifiSsid, info);
+ return;
+ }
- }
+ if (isSoloWifi(trimmedSsid)) {
+ //Attempt to connect to the vehicle.
+ Timber.i("Requesting route to sololink network");
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ connMgr.requestNetwork((NetworkRequest) netReq, (ConnectivityManager.NetworkCallback) netReqCb);
} else {
- notifyWifiConnected(trimmedSsid);
+ notifyWifiConnected(trimmedSsid, info);
}
+ } else {
+ notifyWifiConnected(trimmedSsid, info);
}
}
- private void notifyWifiConnected(String wifiSsid) {
+ private void notifyWifiConnected(String wifiSsid, Bundle extras) {
if (listener != null) {
- listener.onWifiConnected(wifiSsid);
+ listener.onWifiConnected(wifiSsid, extras);
}
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/AssetUtil.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/AssetUtil.java
similarity index 86%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/AssetUtil.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/AssetUtil.java
index c1da75d60e..6ac1e9197a 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/AssetUtil.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/AssetUtil.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.utils.file;
-
-import java.io.IOException;
+package org.droidplanner.services.android.impl.utils.file;
import android.content.res.AssetManager;
+import java.io.IOException;
+
public class AssetUtil {
public static boolean exists(AssetManager assetManager, String directory, String fileName)
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/DirectoryPath.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/DirectoryPath.java
similarity index 56%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/DirectoryPath.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/DirectoryPath.java
index 7db28138e3..d1c77893be 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/DirectoryPath.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/DirectoryPath.java
@@ -1,18 +1,16 @@
-package org.droidplanner.services.android.utils.file;
-
-import java.io.File;
+package org.droidplanner.services.android.impl.utils.file;
import android.content.Context;
import android.os.Environment;
-import org.droidplanner.services.android.R;
+import java.io.File;
public class DirectoryPath {
/**
* Main path used to store private data files related to the program
*
- * @return Path to 3DR Services private data folder in external storage
+ * @return Path to DroneKit-Android private data folder in external storage
*/
static public String getPrivateDataPath(Context context) {
File dataDir = context.getExternalFilesDir(null);
@@ -22,35 +20,13 @@ static public String getPrivateDataPath(Context context) {
/**
* Main path used to store public data files related to the app.
* @param context application context
- * @return Path to 3DR Services public data directory.
+ * @return Path to DroneKit-Android public data directory.
*/
public static String getPublicDataPath(Context context){
final String root = Environment.getExternalStorageDirectory().getPath();
return root + "/3DRServices/";
}
- /**
- * Folder where telemetry log files are stored
- */
- static public File getTLogPath(Context context, String appId) {
- File f = new File(getPrivateDataPath(context) + "/tlogs/" + appId);
- if(!f.exists()) {
- f.mkdirs();
- }
- return f;
- }
-
- /**
- * After tlogs are uploaded they get moved to this directory
- */
- static public File getTLogSentPath(Context context, String appId) {
- File f = new File(getTLogPath(context, appId) + "/sent/");
- if(!f.exists()) {
- f.mkdirs();
- }
- return f;
- }
-
/**
* Storage folder for user camera description files
*/
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoLoader.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoLoader.java
similarity index 94%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoLoader.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoLoader.java
index 8248f0585d..48b1109854 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoLoader.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoLoader.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.utils.file.IO;
+package org.droidplanner.services.android.impl.utils.file.IO;
import android.content.Context;
-import org.droidplanner.services.android.core.survey.CameraInfo;
-import org.droidplanner.services.android.utils.file.FileUtils;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
+import com.o3dr.android.client.utils.FileUtils;
import java.io.File;
import java.io.FileInputStream;
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoReader.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoReader.java
similarity index 96%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoReader.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoReader.java
index 1e085f3212..7c2ffaa00b 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/CameraInfoReader.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/CameraInfoReader.java
@@ -1,13 +1,13 @@
-package org.droidplanner.services.android.utils.file.IO;
+package org.droidplanner.services.android.impl.utils.file.IO;
-import java.io.IOException;
-import java.io.InputStream;
+import android.util.Xml;
-import org.droidplanner.services.android.core.survey.CameraInfo;
+import org.droidplanner.services.android.impl.core.survey.CameraInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import android.util.Xml;
+import java.io.IOException;
+import java.io.InputStream;
/**
* Class to parse a Kml file, based on the code from
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ExceptionWriter.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ExceptionWriter.java
similarity index 81%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ExceptionWriter.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ExceptionWriter.java
index 48ace678a2..fccefae57e 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ExceptionWriter.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ExceptionWriter.java
@@ -1,10 +1,10 @@
-package org.droidplanner.services.android.utils.file.IO;
+package org.droidplanner.services.android.impl.utils.file.IO;
import android.content.Context;
-import java.io.PrintStream;
+import com.o3dr.android.client.utils.FileUtils;
-import org.droidplanner.services.android.utils.file.FileUtils;
+import java.io.PrintStream;
public class ExceptionWriter {
private final Context context;
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ParameterMetadataLoader.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ParameterMetadataLoader.java
similarity index 96%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ParameterMetadataLoader.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ParameterMetadataLoader.java
index e22b1d9397..25b6b9f747 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/ParameterMetadataLoader.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/ParameterMetadataLoader.java
@@ -1,9 +1,9 @@
-package org.droidplanner.services.android.utils.file.IO;
+package org.droidplanner.services.android.impl.utils.file.IO;
import android.content.Context;
import android.util.Xml;
-import org.droidplanner.services.android.core.drone.profiles.ParameterMetadata;
+import org.droidplanner.services.android.impl.core.drone.profiles.ParameterMetadata;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/VehicleProfileReader.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/VehicleProfileReader.java
similarity index 91%
rename from ServiceApp/src/org/droidplanner/services/android/utils/file/IO/VehicleProfileReader.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/VehicleProfileReader.java
index 31f4d21b42..da56cfdee0 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/file/IO/VehicleProfileReader.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/file/IO/VehicleProfileReader.java
@@ -1,4 +1,15 @@
-package org.droidplanner.services.android.utils.file.IO;
+package org.droidplanner.services.android.impl.utils.file.IO;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.util.Xml;
+
+import org.droidplanner.services.android.impl.core.drone.profiles.VehicleProfile;
+import org.droidplanner.services.android.impl.core.firmware.FirmwareType;
+import org.droidplanner.services.android.impl.utils.file.AssetUtil;
+import org.droidplanner.services.android.impl.utils.file.DirectoryPath;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileInputStream;
@@ -6,17 +17,6 @@
import java.io.IOException;
import java.io.InputStream;
-import org.droidplanner.services.android.utils.file.AssetUtil;
-import org.droidplanner.services.android.utils.file.DirectoryPath;
-import org.droidplanner.services.android.core.drone.profiles.VehicleProfile;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.content.Context;
-import android.content.res.AssetManager;
-import android.util.Xml;
-
public class VehicleProfileReader {
private static final String VEHICLEPROFILE_PATH = "VehicleProfiles";
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/video/StreamRecorder.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/StreamRecorder.java
similarity index 99%
rename from ServiceApp/src/org/droidplanner/services/android/utils/video/StreamRecorder.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/StreamRecorder.java
index 08de14fe4e..3b8a36a96d 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/video/StreamRecorder.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/StreamRecorder.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils.video;
+package org.droidplanner.services.android.impl.utils.video;
import android.content.Context;
import android.media.MediaScannerConnection;
@@ -11,6 +11,7 @@
import com.googlecode.mp4parser.authoring.Movie;
import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
import com.googlecode.mp4parser.authoring.tracks.h264.H264TrackImpl;
+
import com.o3dr.android.client.utils.video.MediaCodecManager;
import com.o3dr.android.client.utils.video.NaluChunk;
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/video/VideoManager.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/VideoManager.java
similarity index 97%
rename from ServiceApp/src/org/droidplanner/services/android/utils/video/VideoManager.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/VideoManager.java
index 7856e71329..fc995f6f8c 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/video/VideoManager.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/VideoManager.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils.video;
+package org.droidplanner.services.android.impl.utils.video;
import android.content.Context;
import android.os.Bundle;
@@ -17,6 +17,8 @@
import com.o3dr.services.android.lib.drone.attribute.error.CommandExecutionError;
import com.o3dr.services.android.lib.model.ICommandListener;
+import org.droidplanner.services.android.impl.communication.model.DataLink;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
@@ -44,6 +46,7 @@ public class VideoManager implements IpConnectionListener {
private static final int UDP_BUFFER_SIZE = 1500;
private final AtomicBoolean videoStreamObserverUsed = new AtomicBoolean(false);
+ private final DataLink.DataLinkProvider linkProvider;
public interface LinkListener {
void onLinkConnected();
@@ -56,7 +59,7 @@ public interface LinkListener {
public void run() {
handler.removeCallbacks(reconnectTask);
if(linkConn != null)
- linkConn.connect();
+ linkConn.connect(linkProvider.getConnectionExtras());
}
};
@@ -76,12 +79,13 @@ public void run() {
private int linkPort = -1;
- public VideoManager(Context context, Handler handler) {
+ public VideoManager(Context context, Handler handler, DataLink.DataLinkProvider linkProvider) {
this.streamRecorder = new StreamRecorder(context);
this.handler = handler;
this.mediaCodecManager = new MediaCodecManager(handler);
this.mediaCodecManager.setNaluChunkListener(streamRecorder);
+ this.linkProvider = linkProvider;
}
private void enableLocalRecording(String filename) {
@@ -164,7 +168,7 @@ private void start(int udpPort, LinkListener listener) {
isStarted.set(true);
this.streamRecorder.startConverterThread();
- this.linkConn.connect();
+ this.linkConn.connect(linkProvider.getConnectionExtras());
this.linkListener = listener;
}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/video/file/DecodeH264FromFile.java b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/file/DecodeH264FromFile.java
similarity index 74%
rename from ServiceApp/src/org/droidplanner/services/android/utils/video/file/DecodeH264FromFile.java
rename to ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/file/DecodeH264FromFile.java
index 2facaea140..0d543d71c4 100644
--- a/ServiceApp/src/org/droidplanner/services/android/utils/video/file/DecodeH264FromFile.java
+++ b/ClientLib/src/main/java/org/droidplanner/services/android/impl/utils/video/file/DecodeH264FromFile.java
@@ -1,4 +1,4 @@
-package org.droidplanner.services.android.utils.video.file;
+package org.droidplanner.services.android.impl.utils.video.file;
import android.view.Surface;
diff --git a/ServiceApp/res/drawable-hdpi/ic_stat_notify.png b/ClientLib/src/main/res/drawable-hdpi/ic_stat_notify.png
similarity index 100%
rename from ServiceApp/res/drawable-hdpi/ic_stat_notify.png
rename to ClientLib/src/main/res/drawable-hdpi/ic_stat_notify.png
diff --git a/ServiceApp/res/drawable-mdpi/ic_stat_notify.png b/ClientLib/src/main/res/drawable-mdpi/ic_stat_notify.png
similarity index 100%
rename from ServiceApp/res/drawable-mdpi/ic_stat_notify.png
rename to ClientLib/src/main/res/drawable-mdpi/ic_stat_notify.png
diff --git a/ServiceApp/res/drawable-xhdpi/ic_stat_notify.png b/ClientLib/src/main/res/drawable-xhdpi/ic_stat_notify.png
similarity index 100%
rename from ServiceApp/res/drawable-xhdpi/ic_stat_notify.png
rename to ClientLib/src/main/res/drawable-xhdpi/ic_stat_notify.png
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_stat_notify.png b/ClientLib/src/main/res/drawable-xxhdpi/ic_stat_notify.png
similarity index 100%
rename from ServiceApp/res/drawable-xxhdpi/ic_stat_notify.png
rename to ClientLib/src/main/res/drawable-xxhdpi/ic_stat_notify.png
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_stat_notify.png b/ClientLib/src/main/res/drawable-xxxhdpi/ic_stat_notify.png
similarity index 100%
rename from ServiceApp/res/drawable-xxxhdpi/ic_stat_notify.png
rename to ClientLib/src/main/res/drawable-xxxhdpi/ic_stat_notify.png
diff --git a/ClientLib/src/main/res/layout/activity_install_service_dialog.xml b/ClientLib/src/main/res/layout/activity_install_service_dialog.xml
deleted file mode 100644
index ed97b124f2..0000000000
--- a/ClientLib/src/main/res/layout/activity_install_service_dialog.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/list_item_tlog_info.xml b/ClientLib/src/main/res/layout/list_item_tlog_info.xml
similarity index 100%
rename from ServiceApp/res/layout/list_item_tlog_info.xml
rename to ClientLib/src/main/res/layout/list_item_tlog_info.xml
diff --git a/ClientLib/src/main/res/values-de/strings.xml b/ClientLib/src/main/res/values-de/strings.xml
deleted file mode 100644
index 5ce6f1bf9c..0000000000
--- a/ClientLib/src/main/res/values-de/strings.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- 3DR Services installieren!
- Ihre Version von 3DR Services muss aktualisiert werden, um fortfahren zu können.
- 3DR Services aktualisieren!
- Aktualisieren
- 3DR Services muss auf diesem Gerät installiert sein, um diese App verwenden zu können.
- Installieren
-
diff --git a/ClientLib/src/main/res/values/strings.xml b/ClientLib/src/main/res/values/strings.xml
index 1782a93bab..caa97cbf09 100644
--- a/ClientLib/src/main/res/values/strings.xml
+++ b/ClientLib/src/main/res/values/strings.xml
@@ -1,12 +1,4 @@
- Install 3DR Services!
- 3DR Services must be installed on the device to use this app.
- Install
-
- Update 3DR Services!
- Your version of 3DR Services must be updated to continue.
- Update
-
No error!
Throttle below failsafe
Gyro calibration failed
@@ -73,4 +65,8 @@
Auto-tune
Position Hold
Mission
+
+ Telemetry Log Files
+ Telemetry Logs File Selector
+ Loading data...
diff --git a/ClientLib/src/main/res/values/version.xml b/ClientLib/src/main/res/values/version.xml
index 90de7a4a26..78c64f0969 100644
--- a/ClientLib/src/main/res/values/version.xml
+++ b/ClientLib/src/main/res/values/version.xml
@@ -1,4 +1,4 @@
- 20905
+ 30000
\ No newline at end of file
diff --git a/ServiceApp/res/xml/device_filter.xml b/ClientLib/src/main/res/xml/device_filter.xml
similarity index 100%
rename from ServiceApp/res/xml/device_filter.xml
rename to ClientLib/src/main/res/xml/device_filter.xml
diff --git a/ServiceApp/res/xml/filepaths.xml b/ClientLib/src/main/res/xml/filepaths.xml
similarity index 100%
rename from ServiceApp/res/xml/filepaths.xml
rename to ClientLib/src/main/res/xml/filepaths.xml
diff --git a/ServiceApp/res/xml/google_analytics_tracker.xml b/ClientLib/src/main/res/xml/google_analytics_tracker.xml
similarity index 100%
rename from ServiceApp/res/xml/google_analytics_tracker.xml
rename to ClientLib/src/main/res/xml/google_analytics_tracker.xml
diff --git a/README.md b/README.md
index 96da28b167..b34d5a366d 100644
--- a/README.md
+++ b/README.md
@@ -16,26 +16,17 @@ DroneKit-Android helps you create powerful Android apps for UAVs.
The API provides interfaces that apps can use to control copters, planes, and ground vehicles. It is compatible with vehicles that communicate using the MAVLink protocol (including most vehicles made by 3DR and other members of the DroneCode foundation), and is validated against the open-source [ArduPilot flight control platform](ardupilot.com).
-The project is made of two modules (most developers will use the Client library):
-* [3DR Services App](https://github.com/DroidPlanner/DroneKit-Android/tree/develop/ServiceApp):
-Provided as an apk through the [Google Play store](https://play.google.com/store/apps/details?id=org.droidplanner.services.android&hl=en), this is the layer performing direct
-communication with the 3DR-powered vehicles.
-
-* [DroneKit-Android Client library](http://android.dronekit.io):
-Client library used by Android applications to leverage the functionality provided by the 3DR
-Services layer.
+This project implements the [DroneKit-Android Client library](http://android.dronekit.io) which allows developers to leverage the DroneKit API.
## Getting Started
-The [Getting Started](http://android.dronekit.io/getting_started.html) guide explains how to set up a DroneKit project in Android Studio, install the **3DRServices** app to your device, and start the autopilot simulator (SITL) for testing during development.
+The [Getting Started](http://android.dronekit.io/getting_started.html) guide explains how to set up a DroneKit project in Android Studio, and start the autopilot simulator (SITL) for testing during development.
Once you've got DroneKit set up, the [First App: Hello Drone](http://android.dronekit.io/first_app.html) tutorial provides a step-by-step guide to creating a basic DroneKit-Android app and connecting it to a vehicle.
### Examples
-The [3DR Services](https://play.google.com/store/apps/details?id=org.droidplanner.services.android&hl=en) (Google Play Store) app displays a catalog of Android apps built with DroneKit.
-
-Source code and documentation for some of these apps is linked below:
+Source code and documentation for some of the apps built with DroneKit is linked below:
* [Tower](https://github.com/DroidPlanner/Tower)
* [Tower-Wear](https://github.com/DroidPlanner/tower-wear)
* [Tower-Pebble](https://github.com/DroidPlanner/dp-pebble) ([documentation here](http://android.dronekit.io/pebble_app.html))
@@ -43,7 +34,7 @@ Source code and documentation for some of these apps is linked below:
## Resources
-Project documentation is provided at http://android.dronekit.io/. This includes getting stated and tutorial material, and has has links to [examples](#examples) and the full [Javadoc](http://android.dronekit.io/javadoc/) API Reference.
+Project documentation is provided at http://android.dronekit.io/. This includes getting stated and tutorial material, and has links to [examples](#examples) and the full [Javadoc](http://android.dronekit.io/javadoc/) API Reference.
The [DroneKit Forums](http://discuss.dronekit.io) are the best place to ask for technical support on how to use the library. You can also check out our [Gitter channel](https://gitter.im/dronekit/dronekit-android) though we prefer posts on the forums where possible.
@@ -64,10 +55,7 @@ We welcome all types of contributions but mostly contributions that would help u
## Licence
-[DroneKit-Android Client library](http://android.dronekit.io) is made available under the permissive open source [Apache 2.0 License](https://github.com/dronekit/dronekit-android/blob/develop/ClientLib/LICENSE).
-
-[3DR Services App](https://github.com/DroidPlanner/DroneKit-Android/tree/develop/ServiceApp) is made available under the open source [GPL version 3](https://github.com/dronekit/dronekit-android/blob/develop/ServiceApp/LICENSE.md) licence.
-
+[DroneKit-Android Client library](http://android.dronekit.io) is made available under the permissive open source [Apache 2.0 License](https://github.com/dronekit/dronekit-android/blob/develop/ClientLib/LICENSE).
***
diff --git a/ServiceApp/.gitignore b/ServiceApp/.gitignore
deleted file mode 100644
index 9328249888..0000000000
--- a/ServiceApp/.gitignore
+++ /dev/null
@@ -1,61 +0,0 @@
-# built application files
-*.apk
-*.ap_
-
-# files for the dex VM
-*.dex
-
-# Java class files
-*.class
-
-# generated files
-bin/
-gen/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Eclipse project files
-#.classpath
-#.project
-tmp.txt
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Intellij project files
-*.iml
-*.ipr
-*.iws
-.idea/
-
-*.pydevproject
-#.project
-.metadata
-bin/**
-tmp/**
-tmp/**/*
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-#.classpath
-.settings/
-.loadpath
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-
-#Do not ignore the versioning script
-!.externalToolBuilders/Verisoning.launch
-
-# PDT-specific
-.buildpath
-
-doc/*
diff --git a/ServiceApp/AndroidManifest.xml b/ServiceApp/AndroidManifest.xml
deleted file mode 100644
index fa07164a05..0000000000
--- a/ServiceApp/AndroidManifest.xml
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ServiceApp/LICENSE.md b/ServiceApp/LICENSE.md
deleted file mode 100644
index 369916a906..0000000000
--- a/ServiceApp/LICENSE.md
+++ /dev/null
@@ -1,596 +0,0 @@
-GNU GENERAL PUBLIC LICENSE
-==========================
-
-Version 3, 29 June 2007
-
-Copyright © 2007 Free Software Foundation, Inc. < >
-
-Everyone is permitted to copy and distribute verbatim copies of this license
-document, but changing it is not allowed.
-
-## Preamble
-
-The GNU General Public License is a free, copyleft license for software and other
-kinds of works.
-
-The licenses for most software and other practical works are designed to take away
-your freedom to share and change the works. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change all versions of a
-program--to make sure it remains free software for all its users. We, the Free
-Software Foundation, use the GNU General Public License for most of our software; it
-applies also to any other work released this way by its authors. You can apply it to
-your programs, too.
-
-When we speak of free software, we are referring to freedom, not price. Our General
-Public Licenses are designed to make sure that you have the freedom to distribute
-copies of free software (and charge for them if you wish), that you receive source
-code or can get it if you want it, that you can change the software or use pieces of
-it in new free programs, and that you know you can do these things.
-
-To protect your rights, we need to prevent others from denying you these rights or
-asking you to surrender the rights. Therefore, you have certain responsibilities if
-you distribute copies of the software, or if you modify it: responsibilities to
-respect the freedom of others.
-
-For example, if you distribute copies of such a program, whether gratis or for a fee,
-you must pass on to the recipients the same freedoms that you received. You must make
-sure that they, too, receive or can get the source code. And you must show them these
-terms so they know their rights.
-
-Developers that use the GNU GPL protect your rights with two steps: (1) assert
-copyright on the software, and (2) offer you this License giving you legal permission
-to copy, distribute and/or modify it.
-
-For the developers' and authors' protection, the GPL clearly explains that there is
-no warranty for this free software. For both users' and authors' sake, the GPL
-requires that modified versions be marked as changed, so that their problems will not
-be attributed erroneously to authors of previous versions.
-
-Some devices are designed to deny users access to install or run modified versions of
-the software inside them, although the manufacturer can do so. This is fundamentally
-incompatible with the aim of protecting users' freedom to change the software. The
-systematic pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we have designed
-this version of the GPL to prohibit the practice for those products. If such problems
-arise substantially in other domains, we stand ready to extend this provision to
-those domains in future versions of the GPL, as needed to protect the freedom of
-users.
-
-Finally, every program is threatened constantly by software patents. States should
-not allow patents to restrict development and use of software on general-purpose
-computers, but in those that do, we wish to avoid the special danger that patents
-applied to a free program could make it effectively proprietary. To prevent this, the
-GPL assures that patents cannot be used to render the program non-free.
-
-The precise terms and conditions for copying, distribution and modification follow.
-
-## TERMS AND CONDITIONS
-
-### 0. Definitions.
-
-“This License” refers to version 3 of the GNU General Public License.
-
-“Copyright” also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-“The Program” refers to any copyrightable work licensed under this
-License. Each licensee is addressed as “you”. “Licensees” and
-“recipients” may be individuals or organizations.
-
-To “modify” a work means to copy from or adapt all or part of the work in
-a fashion requiring copyright permission, other than the making of an exact copy. The
-resulting work is called a “modified version” of the earlier work or a
-work “based on” the earlier work.
-
-A “covered work” means either the unmodified Program or a work based on
-the Program.
-
-To “propagate” a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for infringement under
-applicable copyright law, except executing it on a computer or modifying a private
-copy. Propagation includes copying, distribution (with or without modification),
-making available to the public, and in some countries other activities as well.
-
-To “convey” a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through a computer
-network, with no transfer of a copy, is not conveying.
-
-An interactive user interface displays “Appropriate Legal Notices” to the
-extent that it includes a convenient and prominently visible feature that (1)
-displays an appropriate copyright notice, and (2) tells the user that there is no
-warranty for the work (except to the extent that warranties are provided), that
-licensees may convey the work under this License, and how to view a copy of this
-License. If the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-### 1. Source Code.
-
-The “source code” for a work means the preferred form of the work for
-making modifications to it. “Object code” means any non-source form of a
-work.
-
-A “Standard Interface” means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of interfaces
-specified for a particular programming language, one that is widely used among
-developers working in that language.
-
-The “System Libraries” of an executable work include anything, other than
-the work as a whole, that (a) is included in the normal form of packaging a Major
-Component, but which is not part of that Major Component, and (b) serves only to
-enable use of the work with that Major Component, or to implement a Standard
-Interface for which an implementation is available to the public in source code form.
-A “Major Component”, in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system (if any) on which
-the executable work runs, or a compiler used to produce the work, or an object code
-interpreter used to run it.
-
-The “Corresponding Source” for a work in object code form means all the
-source code needed to generate, install, and (for an executable work) run the object
-code and to modify the work, including scripts to control those activities. However,
-it does not include the work's System Libraries, or general-purpose tools or
-generally available free programs which are used unmodified in performing those
-activities but which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for the work, and
-the source code for shared libraries and dynamically linked subprograms that the work
-is specifically designed to require, such as by intimate data communication or
-control flow between those subprograms and other parts of the work.
-
-The Corresponding Source need not include anything that users can regenerate
-automatically from other parts of the Corresponding Source.
-
-The Corresponding Source for a work in source code form is that same work.
-
-### 2. Basic Permissions.
-
-All rights granted under this License are granted for the term of copyright on the
-Program, and are irrevocable provided the stated conditions are met. This License
-explicitly affirms your unlimited permission to run the unmodified Program. The
-output from running a covered work is covered by this License only if the output,
-given its content, constitutes a covered work. This License acknowledges your rights
-of fair use or other equivalent, as provided by copyright law.
-
-You may make, run and propagate covered works that you do not convey, without
-conditions so long as your license otherwise remains in force. You may convey covered
-works to others for the sole purpose of having them make modifications exclusively
-for you, or provide you with facilities for running those works, provided that you
-comply with the terms of this License in conveying all material for which you do not
-control copyright. Those thus making or running the covered works for you must do so
-exclusively on your behalf, under your direction and control, on terms that prohibit
-them from making any copies of your copyrighted material outside their relationship
-with you.
-
-Conveying under any other circumstances is permitted solely under the conditions
-stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
-
-### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-No covered work shall be deemed part of an effective technological measure under any
-applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
-adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
-of such measures.
-
-When you convey a covered work, you waive any legal power to forbid circumvention of
-technological measures to the extent such circumvention is effected by exercising
-rights under this License with respect to the covered work, and you disclaim any
-intention to limit operation or modification of the work as a means of enforcing,
-against the work's users, your or third parties' legal rights to forbid circumvention
-of technological measures.
-
-### 4. Conveying Verbatim Copies.
-
-You may convey verbatim copies of the Program's source code as you receive it, in any
-medium, provided that you conspicuously and appropriately publish on each copy an
-appropriate copyright notice; keep intact all notices stating that this License and
-any non-permissive terms added in accord with section 7 apply to the code; keep
-intact all notices of the absence of any warranty; and give all recipients a copy of
-this License along with the Program.
-
-You may charge any price or no price for each copy that you convey, and you may offer
-support or warranty protection for a fee.
-
-### 5. Conveying Modified Source Versions.
-
-You may convey a work based on the Program, or the modifications to produce it from
-the Program, in the form of source code under the terms of section 4, provided that
-you also meet all of these conditions:
-
-* a) The work must carry prominent notices stating that you modified it, and giving a
-relevant date.
-* b) The work must carry prominent notices stating that it is released under this
-License and any conditions added under section 7. This requirement modifies the
-requirement in section 4 to “keep intact all notices”.
-* c) You must license the entire work, as a whole, under this License to anyone who
-comes into possession of a copy. This License will therefore apply, along with any
-applicable section 7 additional terms, to the whole of the work, and all its parts,
-regardless of how they are packaged. This License gives no permission to license the
-work in any other way, but it does not invalidate such permission if you have
-separately received it.
-* d) If the work has interactive user interfaces, each must display Appropriate Legal
-Notices; however, if the Program has interactive interfaces that do not display
-Appropriate Legal Notices, your work need not make them do so.
-
-A compilation of a covered work with other separate and independent works, which are
-not by their nature extensions of the covered work, and which are not combined with
-it such as to form a larger program, in or on a volume of a storage or distribution
-medium, is called an “aggregate” if the compilation and its resulting
-copyright are not used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work in an aggregate
-does not cause this License to apply to the other parts of the aggregate.
-
-### 6. Conveying Non-Source Forms.
-
-You may convey a covered work in object code form under the terms of sections 4 and
-5, provided that you also convey the machine-readable Corresponding Source under the
-terms of this License, in one of these ways:
-
-* a) Convey the object code in, or embodied in, a physical product (including a
-physical distribution medium), accompanied by the Corresponding Source fixed on a
-durable physical medium customarily used for software interchange.
-* b) Convey the object code in, or embodied in, a physical product (including a
-physical distribution medium), accompanied by a written offer, valid for at least
-three years and valid for as long as you offer spare parts or customer support for
-that product model, to give anyone who possesses the object code either (1) a copy of
-the Corresponding Source for all the software in the product that is covered by this
-License, on a durable physical medium customarily used for software interchange, for
-a price no more than your reasonable cost of physically performing this conveying of
-source, or (2) access to copy the Corresponding Source from a network server at no
-charge.
-* c) Convey individual copies of the object code with a copy of the written offer to
-provide the Corresponding Source. This alternative is allowed only occasionally and
-noncommercially, and only if you received the object code with such an offer, in
-accord with subsection 6b.
-* d) Convey the object code by offering access from a designated place (gratis or for
-a charge), and offer equivalent access to the Corresponding Source in the same way
-through the same place at no further charge. You need not require recipients to copy
-the Corresponding Source along with the object code. If the place to copy the object
-code is a network server, the Corresponding Source may be on a different server
-(operated by you or a third party) that supports equivalent copying facilities,
-provided you maintain clear directions next to the object code saying where to find
-the Corresponding Source. Regardless of what server hosts the Corresponding Source,
-you remain obligated to ensure that it is available for as long as needed to satisfy
-these requirements.
-* e) Convey the object code using peer-to-peer transmission, provided you inform
-other peers where the object code and Corresponding Source of the work are being
-offered to the general public at no charge under subsection 6d.
-
-A separable portion of the object code, whose source code is excluded from the
-Corresponding Source as a System Library, need not be included in conveying the
-object code work.
-
-A “User Product” is either (1) a “consumer product”, which
-means any tangible personal property which is normally used for personal, family, or
-household purposes, or (2) anything designed or sold for incorporation into a
-dwelling. In determining whether a product is a consumer product, doubtful cases
-shall be resolved in favor of coverage. For a particular product received by a
-particular user, “normally used” refers to a typical or common use of
-that class of product, regardless of the status of the particular user or of the way
-in which the particular user actually uses, or expects or is expected to use, the
-product. A product is a consumer product regardless of whether the product has
-substantial commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-“Installation Information” for a User Product means any methods,
-procedures, authorization keys, or other information required to install and execute
-modified versions of a covered work in that User Product from a modified version of
-its Corresponding Source. The information must suffice to ensure that the continued
-functioning of the modified object code is in no case prevented or interfered with
-solely because modification has been made.
-
-If you convey an object code work under this section in, or with, or specifically for
-use in, a User Product, and the conveying occurs as part of a transaction in which
-the right of possession and use of the User Product is transferred to the recipient
-in perpetuity or for a fixed term (regardless of how the transaction is
-characterized), the Corresponding Source conveyed under this section must be
-accompanied by the Installation Information. But this requirement does not apply if
-neither you nor any third party retains the ability to install modified object code
-on the User Product (for example, the work has been installed in ROM).
-
-The requirement to provide Installation Information does not include a requirement to
-continue to provide support service, warranty, or updates for a work that has been
-modified or installed by the recipient, or for the User Product in which it has been
-modified or installed. Access to a network may be denied when the modification itself
-materially and adversely affects the operation of the network or violates the rules
-and protocols for communication across the network.
-
-Corresponding Source conveyed, and Installation Information provided, in accord with
-this section must be in a format that is publicly documented (and with an
-implementation available to the public in source code form), and must require no
-special password or key for unpacking, reading or copying.
-
-### 7. Additional Terms.
-
-“Additional permissions” are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions. Additional
-permissions that are applicable to the entire Program shall be treated as though they
-were included in this License, to the extent that they are valid under applicable
-law. If additional permissions apply only to part of the Program, that part may be
-used separately under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-When you convey a copy of a covered work, you may at your option remove any
-additional permissions from that copy, or from any part of it. (Additional
-permissions may be written to require their own removal in certain cases when you
-modify the work.) You may place additional permissions on material, added by you to a
-covered work, for which you have or can give appropriate copyright permission.
-
-Notwithstanding any other provision of this License, for material you add to a
-covered work, you may (if authorized by the copyright holders of that material)
-supplement the terms of this License with terms:
-
-* a) Disclaiming warranty or limiting liability differently from the terms of
-sections 15 and 16 of this License; or
-* b) Requiring preservation of specified reasonable legal notices or author
-attributions in that material or in the Appropriate Legal Notices displayed by works
-containing it; or
-* c) Prohibiting misrepresentation of the origin of that material, or requiring that
-modified versions of such material be marked in reasonable ways as different from the
-original version; or
-* d) Limiting the use for publicity purposes of names of licensors or authors of the
-material; or
-* e) Declining to grant rights under trademark law for use of some trade names,
-trademarks, or service marks; or
-* f) Requiring indemnification of licensors and authors of that material by anyone
-who conveys the material (or modified versions of it) with contractual assumptions of
-liability to the recipient, for any liability that these contractual assumptions
-directly impose on those licensors and authors.
-
-All other non-permissive additional terms are considered “further
-restrictions” within the meaning of section 10. If the Program as you received
-it, or any part of it, contains a notice stating that it is governed by this License
-along with a term that is a further restriction, you may remove that term. If a
-license document contains a further restriction but permits relicensing or conveying
-under this License, you may add to a covered work material governed by the terms of
-that license document, provided that the further restriction does not survive such
-relicensing or conveying.
-
-If you add terms to a covered work in accord with this section, you must place, in
-the relevant source files, a statement of the additional terms that apply to those
-files, or a notice indicating where to find the applicable terms.
-
-Additional terms, permissive or non-permissive, may be stated in the form of a
-separately written license, or stated as exceptions; the above requirements apply
-either way.
-
-### 8. Termination.
-
-You may not propagate or modify a covered work except as expressly provided under
-this License. Any attempt otherwise to propagate or modify it is void, and will
-automatically terminate your rights under this License (including any patent licenses
-granted under the third paragraph of section 11).
-
-However, if you cease all violation of this License, then your license from a
-particular copyright holder is reinstated (a) provisionally, unless and until the
-copyright holder explicitly and finally terminates your license, and (b) permanently,
-if the copyright holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is reinstated permanently
-if the copyright holder notifies you of the violation by some reasonable means, this
-is the first time you have received notice of violation of this License (for any
-work) from that copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-Termination of your rights under this section does not terminate the licenses of
-parties who have received copies or rights from you under this License. If your
-rights have been terminated and not permanently reinstated, you do not qualify to
-receive new licenses for the same material under section 10.
-
-### 9. Acceptance Not Required for Having Copies.
-
-You are not required to accept this License in order to receive or run a copy of the
-Program. Ancillary propagation of a covered work occurring solely as a consequence of
-using peer-to-peer transmission to receive a copy likewise does not require
-acceptance. However, nothing other than this License grants you permission to
-propagate or modify any covered work. These actions infringe copyright if you do not
-accept this License. Therefore, by modifying or propagating a covered work, you
-indicate your acceptance of this License to do so.
-
-### 10. Automatic Licensing of Downstream Recipients.
-
-Each time you convey a covered work, the recipient automatically receives a license
-from the original licensors, to run, modify and propagate that work, subject to this
-License. You are not responsible for enforcing compliance by third parties with this
-License.
-
-An “entity transaction” is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an organization, or
-merging organizations. If propagation of a covered work results from an entity
-transaction, each party to that transaction who receives a copy of the work also
-receives whatever licenses to the work the party's predecessor in interest had or
-could give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if the predecessor
-has it or can get it with reasonable efforts.
-
-You may not impose any further restrictions on the exercise of the rights granted or
-affirmed under this License. For example, you may not impose a license fee, royalty,
-or other charge for exercise of rights granted under this License, and you may not
-initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
-that any patent claim is infringed by making, using, selling, offering for sale, or
-importing the Program or any portion of it.
-
-### 11. Patents.
-
-A “contributor” is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The work thus
-licensed is called the contributor's “contributor version”.
-
-A contributor's “essential patent claims” are all patent claims owned or
-controlled by the contributor, whether already acquired or hereafter acquired, that
-would be infringed by some manner, permitted by this License, of making, using, or
-selling its contributor version, but do not include claims that would be infringed
-only as a consequence of further modification of the contributor version. For
-purposes of this definition, “control” includes the right to grant patent
-sublicenses in a manner consistent with the requirements of this License.
-
-Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
-under the contributor's essential patent claims, to make, use, sell, offer for sale,
-import and otherwise run, modify and propagate the contents of its contributor
-version.
-
-In the following three paragraphs, a “patent license” is any express
-agreement or commitment, however denominated, not to enforce a patent (such as an
-express permission to practice a patent or covenant not to sue for patent
-infringement). To “grant” such a patent license to a party means to make
-such an agreement or commitment not to enforce a patent against the party.
-
-If you convey a covered work, knowingly relying on a patent license, and the
-Corresponding Source of the work is not available for anyone to copy, free of charge
-and under the terms of this License, through a publicly available network server or
-other readily accessible means, then you must either (1) cause the Corresponding
-Source to be so available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner consistent with
-the requirements of this License, to extend the patent license to downstream
-recipients. “Knowingly relying” means you have actual knowledge that, but
-for the patent license, your conveying the covered work in a country, or your
-recipient's use of the covered work in a country, would infringe one or more
-identifiable patents in that country that you have reason to believe are valid.
-
-If, pursuant to or in connection with a single transaction or arrangement, you
-convey, or propagate by procuring conveyance of, a covered work, and grant a patent
-license to some of the parties receiving the covered work authorizing them to use,
-propagate, modify or convey a specific copy of the covered work, then the patent
-license you grant is automatically extended to all recipients of the covered work and
-works based on it.
-
-A patent license is “discriminatory” if it does not include within the
-scope of its coverage, prohibits the exercise of, or is conditioned on the
-non-exercise of one or more of the rights that are specifically granted under this
-License. You may not convey a covered work if you are a party to an arrangement with
-a third party that is in the business of distributing software, under which you make
-payment to the third party based on the extent of your activity of conveying the
-work, and under which the third party grants, to any of the parties who would receive
-the covered work from you, a discriminatory patent license (a) in connection with
-copies of the covered work conveyed by you (or copies made from those copies), or (b)
-primarily for and in connection with specific products or compilations that contain
-the covered work, unless you entered into that arrangement, or that patent license
-was granted, prior to 28 March 2007.
-
-Nothing in this License shall be construed as excluding or limiting any implied
-license or other defenses to infringement that may otherwise be available to you
-under applicable patent law.
-
-### 12. No Surrender of Others' Freedom.
-
-If conditions are imposed on you (whether by court order, agreement or otherwise)
-that contradict the conditions of this License, they do not excuse you from the
-conditions of this License. If you cannot convey a covered work so as to satisfy
-simultaneously your obligations under this License and any other pertinent
-obligations, then as a consequence you may not convey it at all. For example, if you
-agree to terms that obligate you to collect a royalty for further conveying from
-those to whom you convey the Program, the only way you could satisfy both those terms
-and this License would be to refrain entirely from conveying the Program.
-
-### 13. Use with the GNU Affero General Public License.
-
-Notwithstanding any other provision of this License, you have permission to link or
-combine any covered work with a work licensed under version 3 of the GNU Affero
-General Public License into a single combined work, and to convey the resulting work.
-The terms of this License will continue to apply to the part which is the covered
-work, but the special requirements of the GNU Affero General Public License, section
-13, concerning interaction through a network will apply to the combination as such.
-
-### 14. Revised Versions of this License.
-
-The Free Software Foundation may publish revised and/or new versions of the GNU
-General Public License from time to time. Such new versions will be similar in spirit
-to the present version, but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program specifies that
-a certain numbered version of the GNU General Public License “or any later
-version” applies to it, you have the option of following the terms and
-conditions either of that numbered version or of any later version published by the
-Free Software Foundation. If the Program does not specify a version number of the GNU
-General Public License, you may choose any version ever published by the Free
-Software Foundation.
-
-If the Program specifies that a proxy can decide which future versions of the GNU
-General Public License can be used, that proxy's public statement of acceptance of a
-version permanently authorizes you to choose that version for the Program.
-
-Later license versions may give you additional or different permissions. However, no
-additional obligations are imposed on any author or copyright holder as a result of
-your choosing to follow a later version.
-
-### 15. Disclaimer of Warranty.
-
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
-EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
-QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
-DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-### 16. Limitation of Liability.
-
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
-COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
-PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
-INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
-OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
-WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-### 17. Interpretation of Sections 15 and 16.
-
-If the disclaimer of warranty and limitation of liability provided above cannot be
-given local legal effect according to their terms, reviewing courts shall apply local
-law that most closely approximates an absolute waiver of all civil liability in
-connection with the Program, unless a warranty or assumption of liability accompanies
-a copy of the Program in return for a fee.
-
-END OF TERMS AND CONDITIONS
-
-## How to Apply These Terms to Your New Programs
-
-If you develop a new program, and you want it to be of the greatest possible use to
-the public, the best way to achieve this is to make it free software which everyone
-can redistribute and change under these terms.
-
-To do so, attach the following notices to the program. It is safest to attach them
-to the start of each source file to most effectively state the exclusion of warranty;
-and each file should have at least the “copyright” line and a pointer to
-where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program does terminal interaction, make it output a short notice like this
-when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate parts of
-the General Public License. Of course, your program's commands might be different;
-for a GUI interface, you would use an “about box”.
-
-You should also get your employer (if you work as a programmer) or school, if any, to
-sign a “copyright disclaimer” for the program, if necessary. For more
-information on this, and how to apply and follow the GNU GPL, see
-< >.
-
-The GNU General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may consider it
-more useful to permit linking proprietary applications with the library. If this is
-what you want to do, use the GNU Lesser General Public License instead of this
-License. But first, please read
-<>.
diff --git a/ServiceApp/README.md b/ServiceApp/README.md
deleted file mode 100644
index c17f3a86a7..0000000000
--- a/ServiceApp/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# 3DR Services App
-
-### [3DR Services App](https://play.google.com/store/apps/details?id=org.droidplanner.services.android)
-The app is currently under development, and we would love your help for beta testing.
-To join the beta:
- 1. [Become a beta tester](https://play.google.com/apps/testing/org.droidplanner.services.android)
-, and follow the instructions on the link to download the beta release from the Google Play store (it may take 30+ minutes to show up after becoming a beta tester).
- 2. Send feedback: Post your feedback in the [3DR Services Google+ community](https://plus.google.com/communities/109484130178804610965) or in the [gitter channel](https://gitter.im/dronekit/dronekit-android). We want to hear what you think!
diff --git a/ServiceApp/assets/AppStore/recommendedApps.json b/ServiceApp/assets/AppStore/recommendedApps.json
deleted file mode 100644
index d7810c5f35..0000000000
--- a/ServiceApp/assets/AppStore/recommendedApps.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "apps": [
- {
- "applicationId": "com.o3dr.solo.android",
- "appName": "Solo",
- "appDescription" : "Flight made simple: Use the Solo app to control your 3DR Solo drone.",
- "appIconUrl" : "https://lh3.googleusercontent.com/_rCy-r5n_4TYqbb1nBFBwjCm9vjKDq6LQfsVS-qWSNmOzj7jH1VopvHjr-fFM_NTtN_9=w300-rw"
- },
- {
- "applicationId": "org.droidplanner.android",
- "appName": "Tower",
- "appDescription" : "Tower is 3DR’s powerful and intuitive new flight control program. It provides everything you need to plan, fly and track any 3DR-powered drone.",
- "appIconUrl" : "https://lh5.ggpht.com/3NLRo7-EEUFOCIRPDInbB79-Kbe5CThKpWYUuY3p-eiFcndr-i2kXNRigvu6WvQthSw=w300-rw"
- },
- {
- "applicationId" : "com.o3dr.android.dp.wear",
- "appName" : "Tower Wear",
- "appDescription" : "Tower-Wear is a wear companion app for 3DR Tower.",
- "appIconUrl" : "https://lh5.ggpht.com/8QedcF8g5boPkiq5SB23weUfBtKexIFz28KEvesWPIIIalszbHTLzu-4d7Ey-sbO_Q=w300-rw"
- },
- {
- "applicationId" : "org.droidplanner.pebble",
- "appName" : "Tower Pebble",
- "appDescription" : "Tower-Pebble is a pebble companion app for 3DR Tower.",
- "appIconUrl" : "https://lh3.ggpht.com/1hlm3CaEh9FbLk3QFxDPj7D_sR4E2ex60kGFUOk5H6O5JQfhGgXOFw0RbHIR_P9GgtfO=w300-rw"
- }
- ]
-}
\ No newline at end of file
diff --git a/ServiceApp/build.gradle b/ServiceApp/build.gradle
deleted file mode 100644
index 16882fa486..0000000000
--- a/ServiceApp/build.gradle
+++ /dev/null
@@ -1,248 +0,0 @@
-apply plugin: 'com.android.application'
-apply plugin: 'io.fabric'
-apply plugin: 'com.getkeepsafe.dexcount'
-
-dependencies {
-
- compile "com.google.android.gms:play-services-analytics:${play_services_version}"
- compile "com.google.android.gms:play-services-location:${play_services_version}"
-
- compile "com.android.support:support-v4:${support_lib_version}"
- compile "com.android.support:appcompat-v7:${support_lib_version}"
- compile "com.android.support:cardview-v7:${support_lib_version}"
- compile "com.android.support:recyclerview-v7:${support_lib_version}"
-
- compile files('libs/d2xx.jar')
-
- compile project(':ClientLib')
- compile project(':UsbSerialLibrary')
-
- compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
- transitive = true;
- }
-
- compile 'com.jakewharton.timber:timber:3.1.0'
- compile 'com.jcraft:jsch:0.1.51'
-
- compile "com.squareup.okhttp:okhttp:${okhttp_version}"
- compile "com.squareup.okhttp:okhttp-urlconnection:${okhttp_version}"
-
- //Java semver library
- compile 'com.github.zafarkhaja:java-semver:0.9.0'
-
- //MP4 generation library
- compile 'com.googlecode.mp4parser:isoparser:1.1.7'
-
- testCompile 'junit:junit:4.12'
- testCompile "org.robolectric:robolectric:3.0"
-}
-
-//Decomposed version name and code (https://plus.google.com/+JakeWharton/posts/6f5TcVPRZij)
-def versionMajor = 1
-def versionMinor = 5
-def versionPatch = 3
-def versionBuild = 4 //bump for dogfood builds, public betas, etc.
-def versionPrefix = "3DR Services v"
-
-//Log levels values
-def logLevelVerbose = 2;
-def logLevelDebug = 3;
-def logLevelInfo = 4;
-def logLevelWarn = 5;
-def logLevelError = 6;
-def logLevelAssert = 7;
-
-android {
- compileSdkVersion android_build_sdk_version
- buildToolsVersion android_build_tools_version
-
- defaultConfig {
- applicationId 'org.droidplanner.services.android'
- minSdkVersion android_build_min_sdk_version
- targetSdkVersion android_build_target_sdk_version
- buildConfigField "boolean", "SITL_DEBUG", "false"
- buildConfigField "String", "SOLO_LINK_IP", getSoloLinkIp()
-
- versionCode computeVersionCode(versionMajor, versionMinor, versionPatch, versionBuild)
- versionName generateVersionName(versionPrefix, versionMajor, versionMinor, versionPatch)
-
- //Write logs to file preferences
- buildConfigField "boolean", "WRITE_LOG_FILE", "false"
- buildConfigField "int", "LOG_FILE_LEVEL", "$logLevelDebug"
- buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
-
- // Move the tests to tests/java, tests/res, etc...
- test {
- java.srcDirs = ['test/java']
- }
-
- // Move the build types to build-types/
- // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
- // This moves them out of them default location under src//... which would
- // conflict with src/ being used by the main source set.
- // Adding new build types or product flavors should be accompanied
- // by a similar customization.
- debug.setRoot('build-types/debug')
- release.setRoot('build-types/release')
- }
-
- signingConfigs {
- release {
- storeFile getAppKeystoreFile()
- storePassword getAppKeystorePassword()
- keyAlias getAppKey()
- keyPassword getAppKeyPassword()
- }
- }
-
- android.applicationVariants.all { variant ->
- variant.outputs.each { output ->
- def file = output.outputFile
- if (file != null && file.name.endsWith('.apk')) {
- def buildType = variant.buildType.getName()
- def flavorName = variant.getFlavorName()
- def versionCode = defaultConfig.versionCode
- output.outputFile = new File(file.parent, "3dr-services-${flavorName}-${buildType}.${versionCode}.apk")
- }
- }
- }
-
- android.variantFilter { variant ->
- def flavors = variant.getFlavors()
- if(!flavors.isEmpty()) {
- def flavorName = flavors.get(0).name
- def buildTypeName = variant.buildType.name
-
- //Filter in the variants we interested in building.
- def ignoreVariant = true
- switch (buildTypeName) {
- case "release":
- switch (flavorName) {
- case "alpha":
- case "beta":
- case "prod":
- ignoreVariant = false
- break
- }
- break;
-
- case "debug":
- switch (flavorName) {
- case "dev":
- case "sitl":
- ignoreVariant = false
- break
- }
- break;
-
- case "staging":
- switch (flavorName) {
- case "beta":
- ignoreVariant = false
- break
- }
- break
- }
-
- variant.setIgnore(ignoreVariant);
- }
- }
-
- productFlavors {
- prod {
-
- }
-
- dev {
- versionName generateVersionName(versionPrefix, versionMajor, versionMinor, versionPatch, generateVersionNameSuffix(versionBuild, "dev", true))
- }
-
- beta {
- versionName generateVersionName(versionPrefix, versionMajor, versionMinor, versionPatch, generateVersionNameSuffix(versionBuild, "beta"))
- }
-
- alpha {
- versionName generateVersionName(versionPrefix, versionMajor, versionMinor, versionPatch, generateVersionNameSuffix(versionBuild, "alpha"))
- }
-
- sitl {
- versionName generateVersionName(versionPrefix, versionMajor, versionMinor, versionPatch, generateVersionNameSuffix(versionBuild, "sitl"))
- buildConfigField "String", "SOLO_LINK_IP", getLocalIp()
- buildConfigField "boolean", "SITL_DEBUG", "true"
- }
- }
-
- buildTypes {
- debug {
- debuggable true
- buildConfigField "boolean", "WRITE_LOG_FILE", "true"
- }
-
- staging {
- debuggable true
- signingConfig signingConfigs.release
- buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
- buildConfigField "boolean", "WRITE_LOG_FILE", "true"
- }
-
- release {
- signingConfig signingConfigs.release
- buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
- }
- }
-
- //FIXME: Remove when lint errors are taken care of.
- lintOptions {
- abortOnError false
- }
-
- testOptions {
- unitTests.returnDefaultValues = true
- }
-}
-
-def getAppKeystoreFile() {
- def filePath = hasProperty('COM_O3DR_SERVICES_KEYSTORE') ? COM_O3DR_SERVICES_KEYSTORE : null
- return filePath ? file(filePath) : null
-}
-
-def getAppKeystorePassword(){
- return hasProperty('COM_O3DR_SERVICES_KEYSTORE_PWD') ? COM_O3DR_SERVICES_KEYSTORE_PWD : ''
-}
-
-def getAppKeyPassword() {
- return hasProperty('COM_O3DR_SERVICES_KEY_PWD') ? COM_O3DR_SERVICES_KEY_PWD : ''
-}
-
-def getAppKey() {
- return hasProperty('COM_O3DR_SERVICES_KEY_ALIAS') ? COM_O3DR_SERVICES_KEY_ALIAS : ''
-}
-
-def getSoloLinkIp() {
- return '\"10.1.1.10\"'
-}
-
-def getLocalIp() {
- try {
- return '\"' + InetAddress.getLocalHost().getCanonicalHostName() + '\"'
- }catch(Exception e){
- return '\"\"'
- }
-}
diff --git a/ServiceApp/lint.xml b/ServiceApp/lint.xml
deleted file mode 100644
index 35c04f83ec..0000000000
--- a/ServiceApp/lint.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/proguard.cfg b/ServiceApp/proguard.cfg
deleted file mode 100644
index 6b8f1a3a7e..0000000000
--- a/ServiceApp/proguard.cfg
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Proguard config for the demo project.
-#
-# Author: zdwang@google.com (David Wang)
-#
-
-# Standard config from ADT
-
--dontpreverify
--flattenpackagehierarchy
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--verbose
-
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
-
-# Additional ones needed for Maps API library.
--keepclassmembers class * implements java.io.Serializable { private static final long serialVersionUID; }
--keep public class com.google.googlenav.capabilities.CapabilitiesController*
-
-# Additional config needed for Guava
--keep public interface com.google.common.base.FinalizableReference { void finalizeReferent(); }
-# Missing annotations are harmless.
--dontwarn sun.misc.Unsafe
--dontwarn javax.annotation.**
-# Ignore invalid constant ref. See
-# https://groups.google.com/d/topic/guava-discuss/YCZzeCiIVoI/discussion
--dontwarn com.google.common.collect.MinMaxPriorityQueue
-
-# As described in tools/proguard/examples/android.pro - ignore all warnings.
--dontwarn android.support.v4.**
-
-# Additional config for greenRobot/eventBus
--keepclassmembers class ** {
- public void onEvent*(**);
-}
\ No newline at end of file
diff --git a/ServiceApp/res/drawable-hdpi/ic_android_black_24dp.png b/ServiceApp/res/drawable-hdpi/ic_android_black_24dp.png
deleted file mode 100755
index 6d09039da7..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/ic_android_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/ic_launcher.png b/ServiceApp/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 5ceed5ff40..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/ic_person_black_24dp.png b/ServiceApp/res/drawable-hdpi/ic_person_black_24dp.png
deleted file mode 100755
index 2eeb7c6533..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/ic_person_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/ic_settings_black_24dp.png b/ServiceApp/res/drawable-hdpi/ic_settings_black_24dp.png
deleted file mode 100755
index b16209fc19..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/ic_settings_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/ic_settings_ethernet_black_24dp.png b/ServiceApp/res/drawable-hdpi/ic_settings_ethernet_black_24dp.png
deleted file mode 100755
index f88954f4b8..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/ic_settings_ethernet_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
deleted file mode 100644
index 673e3bf10d..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_selected_holo.9.png
deleted file mode 100644
index d57df98b50..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
deleted file mode 100644
index 6278eef472..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
deleted file mode 100644
index 294991d793..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_holo.9.png
deleted file mode 100644
index 19532ab10d..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png b/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
deleted file mode 100644
index aadc6f87b2..0000000000
Binary files a/ServiceApp/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/ic_android_black_24dp.png b/ServiceApp/res/drawable-mdpi/ic_android_black_24dp.png
deleted file mode 100755
index 119817c670..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/ic_android_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/ic_launcher.png b/ServiceApp/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index f7a7a3d1f0..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/ic_person_black_24dp.png b/ServiceApp/res/drawable-mdpi/ic_person_black_24dp.png
deleted file mode 100755
index 5f44a8ba0f..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/ic_person_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/ic_settings_black_24dp.png b/ServiceApp/res/drawable-mdpi/ic_settings_black_24dp.png
deleted file mode 100755
index 3405c951d2..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/ic_settings_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/ic_settings_ethernet_black_24dp.png b/ServiceApp/res/drawable-mdpi/ic_settings_ethernet_black_24dp.png
deleted file mode 100755
index 529d93dbbd..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/ic_settings_ethernet_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
deleted file mode 100644
index c9972e74bb..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_selected_holo.9.png
deleted file mode 100644
index 587337caf7..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
deleted file mode 100644
index 155c4fc753..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
deleted file mode 100644
index f0cecd183a..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_holo.9.png
deleted file mode 100644
index a2dbf42b74..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png b/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
deleted file mode 100644
index b1223fe3c4..0000000000
Binary files a/ServiceApp/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/ic_android_black_24dp.png b/ServiceApp/res/drawable-xhdpi/ic_android_black_24dp.png
deleted file mode 100755
index 50fbefd5e8..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/ic_android_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/ic_launcher.png b/ServiceApp/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 17bfbe255c..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/ic_person_black_24dp.png b/ServiceApp/res/drawable-xhdpi/ic_person_black_24dp.png
deleted file mode 100755
index ec56af9794..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/ic_person_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/ic_settings_black_24dp.png b/ServiceApp/res/drawable-xhdpi/ic_settings_black_24dp.png
deleted file mode 100755
index 2b775b6465..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/ic_settings_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/ic_settings_ethernet_black_24dp.png b/ServiceApp/res/drawable-xhdpi/ic_settings_ethernet_black_24dp.png
deleted file mode 100755
index c40232db57..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/ic_settings_ethernet_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
deleted file mode 100644
index 03cfb0945d..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_holo.9.png
deleted file mode 100644
index e4229f26b2..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
deleted file mode 100644
index e862cb1215..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
deleted file mode 100644
index f3a5cbde81..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png
deleted file mode 100644
index 9465173781..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png b/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
deleted file mode 100644
index f1eb67323a..0000000000
Binary files a/ServiceApp/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_android_black_24dp.png b/ServiceApp/res/drawable-xxhdpi/ic_android_black_24dp.png
deleted file mode 100755
index b9e0f4dc3b..0000000000
Binary files a/ServiceApp/res/drawable-xxhdpi/ic_android_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_launcher.png b/ServiceApp/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index cd633a3014..0000000000
Binary files a/ServiceApp/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_person_black_24dp.png b/ServiceApp/res/drawable-xxhdpi/ic_person_black_24dp.png
deleted file mode 100755
index 89e82641fa..0000000000
Binary files a/ServiceApp/res/drawable-xxhdpi/ic_person_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_settings_black_24dp.png b/ServiceApp/res/drawable-xxhdpi/ic_settings_black_24dp.png
deleted file mode 100755
index 47f0e0d820..0000000000
Binary files a/ServiceApp/res/drawable-xxhdpi/ic_settings_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxhdpi/ic_settings_ethernet_black_24dp.png b/ServiceApp/res/drawable-xxhdpi/ic_settings_ethernet_black_24dp.png
deleted file mode 100755
index 6c7ca505d4..0000000000
Binary files a/ServiceApp/res/drawable-xxhdpi/ic_settings_ethernet_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_android_black_24dp.png b/ServiceApp/res/drawable-xxxhdpi/ic_android_black_24dp.png
deleted file mode 100755
index da54292923..0000000000
Binary files a/ServiceApp/res/drawable-xxxhdpi/ic_android_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_launcher.png b/ServiceApp/res/drawable-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 2dc210d710..0000000000
Binary files a/ServiceApp/res/drawable-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_person_black_24dp.png b/ServiceApp/res/drawable-xxxhdpi/ic_person_black_24dp.png
deleted file mode 100755
index 3b55aa12b0..0000000000
Binary files a/ServiceApp/res/drawable-xxxhdpi/ic_person_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_settings_black_24dp.png b/ServiceApp/res/drawable-xxxhdpi/ic_settings_black_24dp.png
deleted file mode 100755
index bce161d005..0000000000
Binary files a/ServiceApp/res/drawable-xxxhdpi/ic_settings_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable-xxxhdpi/ic_settings_ethernet_black_24dp.png b/ServiceApp/res/drawable-xxxhdpi/ic_settings_ethernet_black_24dp.png
deleted file mode 100755
index 2cd69e5631..0000000000
Binary files a/ServiceApp/res/drawable-xxxhdpi/ic_settings_ethernet_black_24dp.png and /dev/null differ
diff --git a/ServiceApp/res/drawable/action_button_install_bg.xml b/ServiceApp/res/drawable/action_button_install_bg.xml
deleted file mode 100644
index 1de45da804..0000000000
--- a/ServiceApp/res/drawable/action_button_install_bg.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/drawable/action_button_open_bg.xml b/ServiceApp/res/drawable/action_button_open_bg.xml
deleted file mode 100644
index b0b281017c..0000000000
--- a/ServiceApp/res/drawable/action_button_open_bg.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/drawable/vpi__dark_theme.xml b/ServiceApp/res/drawable/vpi__dark_theme.xml
deleted file mode 100644
index 9a3693eac8..0000000000
--- a/ServiceApp/res/drawable/vpi__dark_theme.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/drawable/vpi__light_theme.xml b/ServiceApp/res/drawable/vpi__light_theme.xml
deleted file mode 100644
index f955db7205..0000000000
--- a/ServiceApp/res/drawable/vpi__light_theme.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ServiceApp/res/drawable/vpi__tab_indicator.xml b/ServiceApp/res/drawable/vpi__tab_indicator.xml
deleted file mode 100644
index 520d08c252..0000000000
--- a/ServiceApp/res/drawable/vpi__tab_indicator.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ServiceApp/res/layout/activity_main.xml b/ServiceApp/res/layout/activity_main.xml
deleted file mode 100644
index a9939dda0f..0000000000
--- a/ServiceApp/res/layout/activity_main.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/activity_tlog_file_selector.xml b/ServiceApp/res/layout/activity_tlog_file_selector.xml
deleted file mode 100644
index e8db2df669..0000000000
--- a/ServiceApp/res/layout/activity_tlog_file_selector.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/activity_usb_intent_receiver.xml b/ServiceApp/res/layout/activity_usb_intent_receiver.xml
deleted file mode 100644
index c8a5a808c2..0000000000
--- a/ServiceApp/res/layout/activity_usb_intent_receiver.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
diff --git a/ServiceApp/res/layout/divider_view.xml b/ServiceApp/res/layout/divider_view.xml
deleted file mode 100644
index 431331d0a9..0000000000
--- a/ServiceApp/res/layout/divider_view.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/fragment_app_connections.xml b/ServiceApp/res/layout/fragment_app_connections.xml
deleted file mode 100644
index afe3005d60..0000000000
--- a/ServiceApp/res/layout/fragment_app_connections.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/fragment_connections.xml b/ServiceApp/res/layout/fragment_connections.xml
deleted file mode 100644
index 81f6fac3be..0000000000
--- a/ServiceApp/res/layout/fragment_connections.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/fragment_recommended_apps.xml b/ServiceApp/res/layout/fragment_recommended_apps.xml
deleted file mode 100644
index 02b49b8ad1..0000000000
--- a/ServiceApp/res/layout/fragment_recommended_apps.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/item_recommended_app_info.xml b/ServiceApp/res/layout/item_recommended_app_info.xml
deleted file mode 100644
index df41a8dde0..0000000000
--- a/ServiceApp/res/layout/item_recommended_app_info.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/layout/list_item_drone_info.xml b/ServiceApp/res/layout/list_item_drone_info.xml
deleted file mode 100644
index 17ef89d137..0000000000
--- a/ServiceApp/res/layout/list_item_drone_info.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ServiceApp/res/menu/activity_main.xml b/ServiceApp/res/menu/activity_main.xml
deleted file mode 100644
index 7510753370..0000000000
--- a/ServiceApp/res/menu/activity_main.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/raw/beep_beep.wav b/ServiceApp/res/raw/beep_beep.wav
deleted file mode 100755
index 2c2a760f24..0000000000
Binary files a/ServiceApp/res/raw/beep_beep.wav and /dev/null differ
diff --git a/ServiceApp/res/values-de/strings.xml b/ServiceApp/res/values-de/strings.xml
deleted file mode 100644
index 80c83c5094..0000000000
--- a/ServiceApp/res/values-de/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- Verbindungen
- Entwickler
- Einstellungen
- Konto
- Hochladung erfolgreich! Klicken um zu sehen…
- Wird später noch einmal versucht
- Droneshare Hochladung
- Entsichern: Schub unterhalb Failsafe
- Navigationsleiste ausblenden
- Navigationsleiste anzeigen
-
- Datenraten
- Rate (in Hz), mit welcher die Flugdaten von der Drohne empfangen werden
- Wegpunkte, GPS Rohdaten, Zaundaten, aktueller Wegpunkt, etc
- Fluglage
- VFR_Hud Daten
- AHRS, Hardware Status, Wind
- Positionsdaten
- RC Übersteuerung
- RC Kanaldaten
- Rohdaten Sensoren
- Rohdaten Kontroller
-
diff --git a/ServiceApp/res/values-it/strings.xml b/ServiceApp/res/values-it/strings.xml
deleted file mode 100644
index 91cf309734..0000000000
--- a/ServiceApp/res/values-it/strings.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- Frequenza di aggiornamento
- Frequenza di aggiornamento dati del Drone (in Hz)
- Waypoint, GPS raw, dati GeoFence , Waypoint attuale etc
- Assetto
- Dati VFR_Hud
- AHRS, Stato Hardware, Vento
- Dati posizione
- RC Override
- Dati canale RC
- Sensore Raw
- Controller Raw
-
diff --git a/ServiceApp/res/values-sw600dp/dimens.xml b/ServiceApp/res/values-sw600dp/dimens.xml
deleted file mode 100644
index 67dc307779..0000000000
--- a/ServiceApp/res/values-sw600dp/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 24dp
-
\ No newline at end of file
diff --git a/ServiceApp/res/values-w720dp/dimens.xml b/ServiceApp/res/values-w720dp/dimens.xml
deleted file mode 100644
index 5fe2df033f..0000000000
--- a/ServiceApp/res/values-w720dp/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 2
- 2
-
\ No newline at end of file
diff --git a/ServiceApp/res/values-zh-rCN/strings.xml b/ServiceApp/res/values-zh-rCN/strings.xml
deleted file mode 100644
index 999a29b9a9..0000000000
--- a/ServiceApp/res/values-zh-rCN/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- 上传成功!选择要查看的…
- 稍后再试
- 上传至Droneshare
- 打开导航抽屉
- 关闭导航抽屉
-
- 流速
- 接收无人机飞行数据的速率(以Hz为单位)
- 航点、GPS原始数据、围栏数据、当前航点等
- 姿态
- VFR_Hud数据
- 航姿系统(AHRS),硬件状态,风速
- 位置数据
- 遥控通道覆盖
- 遥控通道数据
- 传感器原始数据
- 控制器原始数据
-
diff --git a/ServiceApp/res/values-zh-rTW/strings.xml b/ServiceApp/res/values-zh-rTW/strings.xml
deleted file mode 100644
index 470e149b4e..0000000000
--- a/ServiceApp/res/values-zh-rTW/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- 上傳成功!若要檢視,請點選…
- 待會再試試
- 上傳至 Droneshare
- 打開導覽選單
- 關閉覽選單
-
- 資料流速率
- 接收無人機飛行數據的速率(以每 Hz 為單位)
- 航點, GPS 原始資料, fence 資料, 目前航點等
- 姿態
- VFR_Hud 資料
- 航姿系統(AHRS), 硬體狀況, 風
- 位置資料
- 遙控頻道覆蓋
- 遙控頻道資料
- 感測器原始資料
- 伺服原始資料
-
diff --git a/ServiceApp/res/values/arrays.xml b/ServiceApp/res/values/arrays.xml
deleted file mode 100644
index 2c1df96ea7..0000000000
--- a/ServiceApp/res/values/arrays.xml
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
- - Stabilize
- - Acro
- - Alt_Hold
- - Auto
- - Guided
- - Loiter
- - RTL
- - Circle
- - Position
- - Land
- - Of_Loiter
- - Drift
- - Sport
-
-
- - USB
- - TCP
- - UDP
- - BLUETOOTH
-
-
- - 38400
- - 57600
- - 115200
-
-
- - (Mode1) Throttle Right
- - (Mode2) Throttle Left
-
-
- - MODE1
- - MODE2
-
-
- - #
- - Altitude
- - Latitude
- - Longitude
- - P1
- - P2
- - P3
- - P4
-
-
- - Waypoint
- - Ground station
- - Manual entry
-
-
- - Waypoint Type
-
-
- - Auto-tune
- - Roll / Pitch
- - Altitude Hold
- - Loiter
- - Navigation
-
-
- - Do Nothing
- - Flip
- - Simple Mode
- - RTL
- - Save Trim
- - Save WP
- - Multi Mode
- - Camera Trigger
- - Sonar
- - Fence
- - ResetToArmedYaw
- - Super Simple Mode
- - Acro Trainer
- - Auto
- - AutoTune
- - Land
- - EPM
-
-
- - ArduCopter
- - ArduPlane
- - ArduRover
-
-
- - 0;Stabilize
- - 1;Acro
- - 2;AltHold
- - 3;Auto
- - 4;Guided
- - 5;Loiter
- - 6;RTL
- - 7;Circle
- - 8;Position
- - 9;Land
- - 10;OF_Loiter
- - 11;Drift
- - 13;Sport
-
-
- - < 1230
- - 1230 – 1360
- - 1360 – 1490
- - 1490 – 1620
- - 1620 – 1749
- - > 1750
-
-
- - 0;None
- - 1;Stab Roll/Pitch kP
- - 4;Rate Roll/Pitch kP
- - 5;Rate Roll/Pitch kI
- - 21;Rate Roll/Pitch kD
- - 3;Stab Yaw kP
- - 6;Rate Yaw kP
- - 26;Rate Yaw kD
- - 14;Altitude Hold kP
- - 7;Throttle Rate kP
- - 37;Throttle Rate kD
- - 34;Throttle Accel kP
- - 35;Throttle Accel kI
- - 36;Throttle Accel kD
- - 42;Loiter Speed
- - 12;Loiter Pos kP
- - 22;Loiter Rate kP
- - 28;Loiter Rate kI
- - 23;Loiter Rate kD
- - 10;WP Speed
- - 25;Acro RollPitch kP
- - 40;Acro Yaw kP
- - 9;Relay On/Off
- - 13;Heli Ext Gyro
- - 17;OF Loiter kP
- - 18;OF Loiter kI
- - 19;OF Loiter kD
- - 30;AHRS Yaw kP
- - 31;AHRS kP
- - 32;INAV_TC
- - 38;Declination
- - 39;Circle Rate
- - 41;Sonar Gain
-
-
- - 0;Do Nothing
- - 2;Flip
- - 3;Simple Mode
- - 4;RTL
- - 5;Save Trim
- - 7;Save WP
- - 8;Multi Mode
- - 9;Camera Trigger
- - 10;Sonar
- - 11;Fence
- - 12;ResetToArmedYaw
- - 13;Super Simple Mode
- - 14;Acro Trainer
- - 16;Auto
- - 17;AutoTune
- - 18;Land
- - 19;EPM
-
-
- - 0;Disabled
- - 1;RCPassThru
- - 2;Flap
- - 3;Flap_auto
- - 4;Aileron
- - 5;flaperon
- - 6;mount_pan
- - 7;mount_tilt
- - 8;mount_roll
- - 9;mount_open
- - 10;camera_trigger
- - 11;release
- - 12;mount2_pan
- - 13;mount2_tilt
- - 14;mount2_roll
- - 15;mount2_open
- - 16;DifferentialSpoiler1
- - 17;DifferentialSpoiler2
- - 18;AileronWithInput
- - 19;Elevator
- - 20;ElevatorWithInput
- - 21;Rudder
-
-
-
-
- - 0
- - 15
- - 30
- - 45
- - 60
-
-
-
- - No cameras Available
-
-
-
diff --git a/ServiceApp/res/values/attrs.xml b/ServiceApp/res/values/attrs.xml
deleted file mode 100644
index 52058e8c1f..0000000000
--- a/ServiceApp/res/values/attrs.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/values/colors.xml b/ServiceApp/res/values/colors.xml
deleted file mode 100644
index c92606dcd6..0000000000
--- a/ServiceApp/res/values/colors.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- #1C1C1C
- #E6E6E6
- #74D800
-
-
- #ff000000
- #fff3f3f3
- @color/vpi__background_holo_light
- @color/vpi__background_holo_dark
- #ff4c4c4c
- #ffb2b2b2
- @color/vpi__bright_foreground_holo_light
- @color/vpi__bright_foreground_holo_dark
-
\ No newline at end of file
diff --git a/ServiceApp/res/values/dimens.xml b/ServiceApp/res/values/dimens.xml
deleted file mode 100644
index 69fe0ad810..0000000000
--- a/ServiceApp/res/values/dimens.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- 16dp
- 32dp
- 48dp
- 8dp
-
- 1
- 1
-
\ No newline at end of file
diff --git a/ServiceApp/res/values/strings.xml b/ServiceApp/res/values/strings.xml
deleted file mode 100644
index 4fe13c6d06..0000000000
--- a/ServiceApp/res/values/strings.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
- Connections
- Developers
- Settings
- Account
- 3DR Services
- Open navigation drawer
- Close navigation drawer
- Arm: Throttle below failsafe
- Upload successful! Select to view…
- Will try again later
- Droneshare upload
- Telemetry Logs File Selector
- Telemetry Log Files
-
- Stream Rates
- Rate at which flight data should be received from the drone (in Hz)
- Waypoints, GPS raw, fence data, current waypoint, etc
- Attitude
- VFR_Hud data
- AHRS, Hardware Status, Wind
- Position data
- RC Override
- RC Channel Data
- Raw Sensors
- Raw Controller
-
- NO ACTIVE APPS
-
- Learn more
- Install
- Open
- Active
- Recommended
-
-
diff --git a/ServiceApp/res/values/styles.xml b/ServiceApp/res/values/styles.xml
deleted file mode 100644
index f5cc88b5b9..0000000000
--- a/ServiceApp/res/values/styles.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/values/themes.xml b/ServiceApp/res/values/themes.xml
deleted file mode 100644
index ef7074d3cd..0000000000
--- a/ServiceApp/res/values/themes.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/xml-zh-rCN/checklist_default.xml b/ServiceApp/res/xml-zh-rCN/checklist_default.xml
deleted file mode 100644
index a19d8e3cb0..0000000000
--- a/ServiceApp/res/xml-zh-rCN/checklist_default.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/xml-zh-rCN/checklist_full.xml b/ServiceApp/res/xml-zh-rCN/checklist_full.xml
deleted file mode 100644
index 78ec355bd4..0000000000
--- a/ServiceApp/res/xml-zh-rCN/checklist_full.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/res/xml/preferences.xml b/ServiceApp/res/xml/preferences.xml
deleted file mode 100644
index 08b4644ec4..0000000000
--- a/ServiceApp/res/xml/preferences.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ServiceApp/src/org/droidplanner/services/android/DroidPlannerServicesApp.java b/ServiceApp/src/org/droidplanner/services/android/DroidPlannerServicesApp.java
deleted file mode 100644
index 55c664aed8..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/DroidPlannerServicesApp.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.droidplanner.services.android;
-
-import android.app.Application;
-
-import com.crashlytics.android.Crashlytics;
-
-import org.droidplanner.services.android.utils.LogToFileTree;
-import org.droidplanner.services.android.utils.analytics.GAUtils;
-import org.droidplanner.services.android.utils.file.IO.ExceptionWriter;
-
-import io.fabric.sdk.android.Fabric;
-import timber.log.Timber;
-
-public class DroidPlannerServicesApp extends Application {
-
- private LogToFileTree logToFileTree;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- if(BuildConfig.ENABLE_CRASHLYTICS) {
- Fabric.with(this, new Crashlytics());
- }
-
- if (BuildConfig.WRITE_LOG_FILE) {
- logToFileTree = new LogToFileTree();
- Timber.plant(logToFileTree);
- } else if (BuildConfig.DEBUG) {
- Timber.plant(new Timber.DebugTree());
- }
-
- final ExceptionWriter exceptionWriter = new ExceptionWriter(getApplicationContext());
- final Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
-
- final Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
- @Override
- public void uncaughtException(Thread thread, Throwable ex) {
- exceptionWriter.saveStackTraceToSD(ex);
- defaultHandler.uncaughtException(thread, ex);
- }
- };
-
- Thread.setDefaultUncaughtExceptionHandler(handler);
-
- GAUtils.initGATracker(this);
- GAUtils.startNewSession(null);
- }
-
- public void createFileStartLogging() {
- if (logToFileTree != null) {
- logToFileTree.createFileStartLogging(getApplicationContext());
- }
- }
-
- public void closeLogFile() {
- if(logToFileTree != null) {
- logToFileTree.stopLoggingThread();
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/api/DroneAccess.java b/ServiceApp/src/org/droidplanner/services/android/api/DroneAccess.java
deleted file mode 100644
index cb24196bb0..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/api/DroneAccess.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.droidplanner.services.android.api;
-
-import android.os.Binder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
-* Created by fhuya on 11/3/14.
-*/
-public final class DroneAccess extends Binder {
-
- private final DroidPlannerService serviceRef;
-
- DroneAccess(DroidPlannerService service) {
- serviceRef = service;
- }
-
- public List getDroneApiList() {
- return new ArrayList<>(serviceRef.droneApiStore.values());
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidMavLinkConnection.java b/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidMavLinkConnection.java
deleted file mode 100644
index 3e8d35bd25..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/communication/connection/AndroidMavLinkConnection.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.droidplanner.services.android.communication.connection;
-
-import android.content.Context;
-
-import org.droidplanner.services.android.core.MAVLink.connection.MavLinkConnection;
-import org.droidplanner.services.android.core.model.Logger;
-import org.droidplanner.services.android.utils.AndroidLogger;
-
-public abstract class AndroidMavLinkConnection extends MavLinkConnection {
-
- protected final Context mContext;
-
- public AndroidMavLinkConnection(Context applicationContext) {
- this.mContext = applicationContext;
- }
-
- @Override
- protected final Logger initLogger() {
- return AndroidLogger.getLogger();
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionTypes.java b/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionTypes.java
deleted file mode 100644
index 99aab6bd59..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/core/MAVLink/connection/MavLinkConnectionTypes.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.droidplanner.services.android.core.MAVLink.connection;
-
-/**
- * List the supported mavlink connection types.
- */
-public class MavLinkConnectionTypes {
-
- /**
- * Bluetooth mavlink connection.
- */
- public static final int MAVLINK_CONNECTION_BLUETOOTH = 3;
-
- /**
- * USP mavlink connection.
- */
- public static final int MAVLINK_CONNECTION_USB = 0;
-
- /**
- * UDP mavlink connection.
- */
- public static final int MAVLINK_CONNECTION_UDP = 1;
-
- /**
- * TCP mavlink connection.
- */
- public static final int MAVLINK_CONNECTION_TCP = 2;
-
- public static String getConnectionTypeLabel(int connectionType){
- switch(connectionType){
- case MavLinkConnectionTypes.MAVLINK_CONNECTION_BLUETOOTH:
- return "bluetooth";
-
- case MavLinkConnectionTypes.MAVLINK_CONNECTION_TCP:
- return "tcp";
-
- case MavLinkConnectionTypes.MAVLINK_CONNECTION_UDP:
- return "udp";
-
- case MavLinkConnectionTypes.MAVLINK_CONNECTION_USB:
- return "usb";
-
- default:
- return null;
- }
- }
-
- // Not instantiable
- private MavLinkConnectionTypes() {
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneEvents.java b/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneEvents.java
deleted file mode 100644
index df5b0d4d7f..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/DroneEvents.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.droidplanner.services.android.core.drone;
-
-import android.os.Handler;
-
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class DroneEvents extends DroneVariable {
-
- private static final long EVENT_DISPATCHING_DELAY = 33l; //milliseconds
-
- private final AtomicBoolean isDispatcherRunning = new AtomicBoolean(false);
-
- private final Runnable eventDispatcher = new Runnable() {
-
- @Override
- public void run() {
- handler.removeCallbacks(this);
-
- final DroneEventsType event = eventQueue.poll();
- if (event == null) {
- isDispatcherRunning.set(false);
- return;
- }
-
- for (OnDroneListener listener : droneListeners) {
- listener.onDroneEvent(event, myDrone);
- }
-
- handler.removeCallbacks(this);
- handler.postDelayed(this, EVENT_DISPATCHING_DELAY);
-
- isDispatcherRunning.set(true);
- }
- };
-
- private final Handler handler;
-
- public DroneEvents(MavLinkDrone myDrone, Handler handler) {
- super(myDrone);
- this.handler = handler;
- }
-
- private final ConcurrentLinkedQueue droneListeners = new ConcurrentLinkedQueue();
- private final ConcurrentLinkedQueue eventQueue = new ConcurrentLinkedQueue<>();
-
- public void addDroneListener(OnDroneListener listener) {
- if (listener != null & !droneListeners.contains(listener))
- droneListeners.add(listener);
- }
-
- public void removeDroneListener(OnDroneListener listener) {
- if (listener != null && droneListeners.contains(listener))
- droneListeners.remove(listener);
- }
-
- public void removeAllDroneListeners(){
- droneListeners.clear();
- }
-
- public void notifyDroneEvent(DroneEventsType event) {
- if (event == null || droneListeners.isEmpty() || eventQueue.contains(event))
- return;
-
- eventQueue.add(event);
- if (isDispatcherRunning.compareAndSet(false, true))
- handler.postDelayed(eventDispatcher, EVENT_DISPATCHING_DELAY);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/Preferences.java b/ServiceApp/src/org/droidplanner/services/android/core/drone/Preferences.java
deleted file mode 100644
index 0f62fe7e2d..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/Preferences.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.droidplanner.services.android.core.drone;
-
-import org.droidplanner.services.android.core.drone.profiles.VehicleProfile;
-import org.droidplanner.services.android.core.drone.variables.StreamRates;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-
-public interface Preferences {
-
- public abstract VehicleProfile loadVehicleProfile(FirmwareType firmwareType);
-
- public StreamRates.Rates getRates();
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/MavLinkDrone.java b/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/MavLinkDrone.java
deleted file mode 100644
index 736367bdcc..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/autopilot/MavLinkDrone.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.droidplanner.services.android.core.drone.autopilot;
-
-import com.MAVLink.Messages.MAVLinkMessage;
-
-import org.droidplanner.services.android.communication.model.DataLink;
-import org.droidplanner.services.android.core.MAVLink.WaypointManager;
-import org.droidplanner.services.android.core.drone.profiles.ParameterManager;
-import org.droidplanner.services.android.core.drone.variables.Camera;
-import org.droidplanner.services.android.core.drone.variables.GuidedPoint;
-import org.droidplanner.services.android.core.drone.variables.MissionStats;
-import org.droidplanner.services.android.core.drone.variables.State;
-import org.droidplanner.services.android.core.drone.variables.StreamRates;
-import org.droidplanner.services.android.core.drone.variables.calibration.AccelCalibration;
-import org.droidplanner.services.android.core.drone.variables.calibration.MagnetometerCalibrationImpl;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.core.mission.Mission;
-
-public interface MavLinkDrone extends Drone {
-
- String PACKAGE_NAME = "org.droidplanner.services.android.core.drone.autopilot";
-
- String ACTION_REQUEST_HOME_UPDATE = PACKAGE_NAME + ".action.REQUEST_HOME_UPDATE";
-
- boolean isConnectionAlive();
-
- int getMavlinkVersion();
-
- void onMavLinkMessageReceived(MAVLinkMessage message);
-
- public byte getSysid();
-
- public byte getCompid();
-
- public State getState();
-
- public ParameterManager getParameterManager();
-
- public int getType();
-
- public FirmwareType getFirmwareType();
-
- public DataLink.DataLinkProvider getMavClient();
-
- public WaypointManager getWaypointManager();
-
- public Mission getMission();
-
- public StreamRates getStreamRates();
-
- public MissionStats getMissionStats();
-
- public GuidedPoint getGuidedPoint();
-
- public AccelCalibration getCalibrationSetup();
-
- public MagnetometerCalibrationImpl getMagnetometerCalibration();
-
- public String getFirmwareVersion();
-
- public Camera getCamera();
-
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/StreamRates.java b/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/StreamRates.java
deleted file mode 100644
index d79d5fb747..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/core/drone/variables/StreamRates.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.droidplanner.services.android.core.drone.variables;
-
-import org.droidplanner.services.android.core.MAVLink.MavLinkStreamRates;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.DroneEventsType;
-import org.droidplanner.services.android.core.drone.DroneInterfaces.OnDroneListener;
-import org.droidplanner.services.android.core.drone.DroneVariable;
-import org.droidplanner.services.android.core.drone.autopilot.MavLinkDrone;
-
-public class StreamRates extends DroneVariable implements OnDroneListener {
-
- private Rates rates;
-
- public StreamRates(MavLinkDrone myDrone) {
- super(myDrone);
- myDrone.addDroneListener(this);
- }
-
- public void setRates(Rates rates) {
- this.rates = rates;
- }
-
- @Override
- public void onDroneEvent(DroneEventsType event, MavLinkDrone drone) {
- switch (event) {
- case CONNECTED:
- case HEARTBEAT_FIRST:
- case HEARTBEAT_RESTORED:
- setupStreamRatesFromPref();
- break;
- default:
- break;
- }
- }
-
- public void setupStreamRatesFromPref() {
- if(rates == null)
- return;
-
- MavLinkStreamRates.setupStreamRates(myDrone.getMavClient(), myDrone.getSysid(),
- myDrone.getCompid(), rates.extendedStatus, rates.extra1, rates.extra2,
- rates.extra3, rates.position, rates.rcChannels, rates.rawSensors,
- rates.rawController);
- }
-
- public static class Rates {
- public int extendedStatus;
- public int extra1;
- public int extra2;
- public int extra3;
- public int position;
- public int rcChannels;
- public int rawSensors;
- public int rawController;
-
- public Rates(){}
-
- public Rates(int rate){
- this.extendedStatus = rate;
- this.extra1 = rate;
- this.extra2 = rate;
- this.extra3 = rate;
- this.position = rate;
- this.rcChannels = rate;
- this.rawSensors = rate;
- this.rawController = rate;
- }
- }
-
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/data/SessionContract.java b/ServiceApp/src/org/droidplanner/services/android/data/SessionContract.java
deleted file mode 100644
index 61776093ad..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/data/SessionContract.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.droidplanner.services.android.data;
-
-import android.provider.BaseColumns;
-
-/**
- * Defines the schema for the Session database.
- */
-public final class SessionContract {
-
- public static final String DB_NAME = "session";
- public static final int DB_VERSION = 2;
-
- //Private constructor to prevent instantiation.
- private SessionContract(){}
-
- public static String getSqlCreateEntries(){
- return SessionData.SQL_CREATE_ENTRIES;
- }
-
- public static String getSqlDeleteEntries(){
- return SessionData.SQL_DELETE_ENTRIES;
- }
-
- /**
- * Defines the schema for the SessionData table.
- */
- public static final class SessionData implements BaseColumns {
- public static final String TABLE_NAME = "session_data";
-
- public static final String COLUMN_NAME_APP_ID = "app_id";
- public static final String COLUMN_NAME_START_TIME ="start_time";
- public static final String COLUMN_NAME_END_TIME = "end_time";
- public static final String COLUMN_NAME_CONNECTION_TYPE = "connection_type";
- public static final String COLUMN_NAME_DSHARE_UPLOAD_TIME = "dshare_upload_time";
-
- public static final String SQL_CREATE_ENTRIES =
- "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" +
- _ID + " INTEGER PRIMARY KEY," +
- COLUMN_NAME_APP_ID + " TEXT," +
- COLUMN_NAME_START_TIME + " INTEGER NOT NULL," +
- COLUMN_NAME_END_TIME + " INTEGER," +
- COLUMN_NAME_CONNECTION_TYPE + " TEXT," +
- COLUMN_NAME_DSHARE_UPLOAD_TIME + " INTEGER" +
- " )";
-
- public static final String SQL_DELETE_ENTRIES =
- "DROP TABLE IF EXISTS " + TABLE_NAME;
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/data/SessionDB.java b/ServiceApp/src/org/droidplanner/services/android/data/SessionDB.java
deleted file mode 100644
index b6aa78a38b..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/data/SessionDB.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.droidplanner.services.android.data;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
-
-import java.util.Date;
-
-import org.droidplanner.services.android.data.SessionContract.SessionData;
-
-/**
- * Created by fhuya on 12/30/14.
- */
-public class SessionDB extends SQLiteOpenHelper {
-
- private static final String TAG = SessionDB.class.getSimpleName();
-
- public SessionDB(Context context) {
- super(context, SessionContract.DB_NAME, null, SessionContract.DB_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- Log.d(TAG, "Creating session database.");
- db.execSQL(SessionContract.getSqlCreateEntries());
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL(SessionContract.getSqlDeleteEntries());
- onCreate(db);
- }
-
- public void startSession(Date startDate, String connectionType){
- //Get the data repository in write mode.
- SQLiteDatabase db = getWritableDatabase();
-
- ContentValues values = new ContentValues();
- values.put(SessionData.COLUMN_NAME_START_TIME, startDate.getTime());
- values.put(SessionData.COLUMN_NAME_CONNECTION_TYPE, connectionType);
-
- db.insert(SessionData.TABLE_NAME, null, values);
- }
-
- public void endSession(Date startDate, String connectionType, Date endDate){
- SQLiteDatabase db = getWritableDatabase();
-
- ContentValues values = new ContentValues();
- values.put(SessionData.COLUMN_NAME_END_TIME, endDate.getTime());
-
- String selection = SessionData.COLUMN_NAME_START_TIME + " LIKE ? AND " + SessionData
- .COLUMN_NAME_CONNECTION_TYPE + " LIKE ?";
- String[] selectionArgs = {String.valueOf(startDate.getTime()), connectionType};
-
- db.update(SessionData.TABLE_NAME, values, selection, selectionArgs);
- }
-
- public void updateDroneShareUploadTime(Date startDate, String connectionType, Date uploadDate){
- SQLiteDatabase db = getWritableDatabase();
-
- ContentValues values = new ContentValues();
- values.put(SessionData.COLUMN_NAME_DSHARE_UPLOAD_TIME, uploadDate.getTime());
-
- String selection = SessionData.COLUMN_NAME_START_TIME + " LIKE ? AND " + SessionData
- .COLUMN_NAME_CONNECTION_TYPE + " LIKE ?";
- String[] selectionArgs = {String.valueOf(startDate.getTime()), connectionType};
-
- db.update(SessionData.TABLE_NAME, values, selection, selectionArgs);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/data/provider/FileProvider.java b/ServiceApp/src/org/droidplanner/services/android/data/provider/FileProvider.java
deleted file mode 100644
index 0c2113ebae..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/data/provider/FileProvider.java
+++ /dev/null
@@ -1,757 +0,0 @@
-package org.droidplanner.services.android.data.provider;
-
-import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
-import static org.xmlpull.v1.XmlPullParser.START_TAG;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ProviderInfo;
-import android.content.res.XmlResourceParser;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.net.Uri;
-import android.os.Environment;
-import android.os.ParcelFileDescriptor;
-import android.provider.OpenableColumns;
-import android.text.TextUtils;
-import android.webkit.MimeTypeMap;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * FileProvider is a special subclass of {@link ContentProvider} that facilitates secure sharing
- * of files associated with an app by creating a content://
{@link Uri} for a file
- * instead of a file:///
{@link Uri}.
- *
- * A content URI allows you to grant read and write access using
- * temporary access permissions. When you create an {@link Intent} containing
- * a content URI, in order to send the content URI
- * to a client app, you can also call {@link Intent#setFlags(int) Intent.setFlags()} to add
- * permissions. These permissions are available to the client app for as long as the stack for
- * a receiving {@link android.app.Activity} is active. For an {@link Intent} going to a
- * {@link android.app.Service}, the permissions are available as long as the
- * {@link android.app.Service} is running.
- *
- * In comparison, to control access to a file:///
{@link Uri} you have to modify the
- * file system permissions of the underlying file. The permissions you provide become available to
- * any app, and remain in effect until you change them. This level of access is
- * fundamentally insecure.
- *
- * The increased level of file access security offered by a content URI
- * makes FileProvider a key part of Android's security infrastructure.
- *
- * This overview of FileProvider includes the following topics:
- *
- *
- * Defining a FileProvider
- * Specifying Available Files
- * Retrieving the Content URI for a File
- * Granting Temporary Permissions to a URI
- * Serving a Content URI to Another App
- *
- * Defining a FileProvider
- *
- * Since the default functionality of FileProvider includes content URI generation for files, you
- * don't need to define a subclass in code. Instead, you can include a FileProvider in your app
- * by specifying it entirely in XML. To specify the FileProvider component itself, add a
- * <provider>
- * element to your app manifest. Set the android:name
attribute to
- * android.support.v4.content.FileProvider
. Set the android:authorities
- * attribute to a URI authority based on a domain you control; for example, if you control the
- * domain mydomain.com
you should use the authority
- * com.mydomain.fileprovider
. Set the android:exported
attribute to
- * false
; the FileProvider does not need to be public. Set the
- * android:grantUriPermissions attribute to true
, to allow you
- * to grant temporary access to files. For example:
- *
- *<manifest>
- * ...
- * <application>
- * ...
- * <provider
- * android:name="android.support.v4.content.FileProvider"
- * android:authorities="com.mydomain.fileprovider"
- * android:exported="false"
- * android:grantUriPermissions="true">
- * ...
- * </provider>
- * ...
- * </application>
- *</manifest>
- *
- * If you want to override any of the default behavior of FileProvider methods, extend
- * the FileProvider class and use the fully-qualified class name in the android:name
- * attribute of the <provider>
element.
- *
Specifying Available Files
- * A FileProvider can only generate a content URI for files in directories that you specify
- * beforehand. To specify a directory, specify the its storage area and path in XML, using child
- * elements of the <paths>
element.
- * For example, the following paths
element tells FileProvider that you intend to
- * request content URIs for the images/
subdirectory of your private file area.
- *
- *<paths xmlns:android="http://schemas.android.com/apk/res/android">
- * <files-path name="my_images" path="images/"/>
- * ...
- *</paths>
- *
- *
- * The <paths>
element must contain one or more of the following child elements:
- *
- *
- *
- *
- *<files-path name="name " path="path " />
- *
- *
- *
- * Represents files in the files/
subdirectory of your app's internal storage
- * area. This subdirectory is the same as the value returned by {@link Context#getFilesDir()
- * Context.getFilesDir()}.
- *
- *
- *<external-path name="name " path="path " />
- *
- *
- *
- * Represents files in the root of your app's external storage area. The path
- * {@link Context#getExternalFilesDir(String) Context.getExternalFilesDir()} returns the
- * files/
subdirectory of this this root.
- *
- *
- *
- *<cache-path name="name " path="path " />
- *
- *
- *
- * Represents files in the cache subdirectory of your app's internal storage area. The root path
- * of this subdirectory is the same as the value returned by {@link Context#getCacheDir()
- * getCacheDir()}.
- *
- *
- *
- * These child elements all use the same attributes:
- *
- *
- *
- * name="name "
- *
- *
- * A URI path segment. To enforce security, this value hides the name of the subdirectory
- * you're sharing. The subdirectory name for this value is contained in the
- * path
attribute.
- *
- *
- * path="path "
- *
- *
- * The subdirectory you're sharing. While the name
attribute is a URI path
- * segment, the path
value is an actual subdirectory name. Notice that the
- * value refers to a subdirectory , not an individual file or files. You can't
- * share a single file by its file name, nor can you specify a subset of files using
- * wildcards.
- *
- *
- *
- * You must specify a child element of <paths>
for each directory that contains
- * files for which you want content URIs. For example, these XML elements specify two directories:
- *
- *<paths xmlns:android="http://schemas.android.com/apk/res/android">
- * <files-path name="my_images" path="images/"/>
- * <files-path name="my_docs" path="docs/"/>
- *</paths>
- *
- *
- * Put the <paths>
element and its children in an XML file in your project.
- * For example, you can add them to a new file called res/xml/file_paths.xml
.
- * To link this file to the FileProvider, add a
- * <meta-data> element
- * as a child of the <provider>
element that defines the FileProvider. Set the
- * <meta-data>
element's "android:name" attribute to
- * android.support.FILE_PROVIDER_PATHS
. Set the element's "android:resource" attribute
- * to @xml/file_paths
(notice that you don't specify the .xml
- * extension). For example:
- *
- *<provider
- * android:name="android.support.v4.content.FileProvider"
- * android:authorities="com.mydomain.fileprovider"
- * android:exported="false"
- * android:grantUriPermissions="true">
- * <meta-data
- * android:name="android.support.FILE_PROVIDER_PATHS"
- * android:resource="@xml/file_paths" />
- *</provider>
- *
- * Generating the Content URI for a File
- *
- * To share a file with another app using a content URI, your app has to generate the content URI.
- * To generate the content URI, create a new {@link File} for the file, then pass the {@link File}
- * to {@link #getUriForFile(Context, String, File) getUriForFile()}. You can send the content URI
- * returned by {@link #getUriForFile(Context, String, File) getUriForFile()} to another app in an
- * {@link android.content.Intent}. The client app that receives the content URI can open the file
- * and access its contents by calling
- * {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
- * ContentResolver.openFileDescriptor} to get a {@link ParcelFileDescriptor}.
- *
- * For example, suppose your app is offering files to other apps with a FileProvider that has the
- * authority com.mydomain.fileprovider
. To get a content URI for the file
- * default_image.jpg
in the images/
subdirectory of your internal storage
- * add the following code:
- *
- *File imagePath = new File(Context.getFilesDir(), "images");
- *File newFile = new File(imagePath, "default_image.jpg");
- *Uri contentUri = getUriForFile(getContext(), "com.mydomain.fileprovider", newFile);
- *
- * As a result of the previous snippet,
- * {@link #getUriForFile(Context, String, File) getUriForFile()} returns the content URI
- * content://com.mydomain.fileprovider/my_images/default_image.jpg
.
- * Granting Temporary Permissions to a URI
- * To grant an access permission to a content URI returned from
- * {@link #getUriForFile(Context, String, File) getUriForFile()}, do one of the following:
- *
- *
- * Call the method
- * {@link Context#grantUriPermission(String, Uri, int)
- * Context.grantUriPermission(package, Uri, mode_flags)} for the content://
- * {@link Uri}, using the desired mode flags. This grants temporary access permission for the
- * content URI to the specified package, according to the value of the
- * the mode_flags
parameter, which you can set to
- * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}, {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}
- * or both. The permission remains in effect until you revoke it by calling
- * {@link Context#revokeUriPermission(Uri, int) revokeUriPermission()} or until the device
- * reboots.
- *
- *
- * Put the content URI in an {@link Intent} by calling {@link Intent#setData(Uri) setData()}.
- *
- *
- * Next, call the method {@link Intent#setFlags(int) Intent.setFlags()} with either
- * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} or
- * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION} or both.
- *
- *
- * Finally, send the {@link Intent} to
- * another app. Most often, you do this by calling
- * {@link android.app.Activity#setResult(int, android.content.Intent) setResult()}.
- *
- * Permissions granted in an {@link Intent} remain in effect while the stack of the receiving
- * {@link android.app.Activity} is active. When the stack finishes, the permissions are
- * automatically removed. Permissions granted to one {@link android.app.Activity} in a client
- * app are automatically extended to other components of that app.
- *
- *
- *
- * Serving a Content URI to Another App
- *
- * There are a variety of ways to serve the content URI for a file to a client app. One common way
- * is for the client app to start your app by calling
- * {@link android.app.Activity#startActivityForResult(Intent, int, Bundle) startActivityResult()},
- * which sends an {@link Intent} to your app to start an {@link android.app.Activity} in your app.
- * In response, your app can immediately return a content URI to the client app or present a user
- * interface that allows the user to pick a file. In the latter case, once the user picks the file
- * your app can return its content URI. In both cases, your app returns the content URI in an
- * {@link Intent} sent via {@link android.app.Activity#setResult(int, Intent) setResult()}.
- *
- *
- * You can also put the content URI in a {@link android.content.ClipData} object and then add the
- * object to an {@link Intent} you send to a client app. To do this, call
- * {@link Intent#setClipData(ClipData) Intent.setClipData()}. When you use this approach, you can
- * add multiple {@link android.content.ClipData} objects to the {@link Intent}, each with its own
- * content URI. When you call {@link Intent#setFlags(int) Intent.setFlags()} on the {@link Intent}
- * to set temporary access permissions, the same permissions are applied to all of the content
- * URIs.
- *
- *
- * Note: The {@link Intent#setClipData(ClipData) Intent.setClipData()} method is
- * only available in platform version 16 (Android 4.1) and later. If you want to maintain
- * compatibility with previous versions, you should send one content URI at a time in the
- * {@link Intent}. Set the action to {@link Intent#ACTION_SEND} and put the URI in data by calling
- * {@link Intent#setData setData()}.
- *
- * More Information
- *
- * To learn more about FileProvider, see the Android training class
- * Sharing Files Securely with URIs .
- *
- */
-public class FileProvider extends ContentProvider {
- private static final String[] COLUMNS = {
- OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE };
-
- private static final String
- META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
-
- private static final String TAG_ROOT_PATH = "root-path";
- private static final String TAG_FILES_PATH = "files-path";
- private static final String TAG_CACHE_PATH = "cache-path";
- private static final String TAG_EXTERNAL = "external-path";
-
- private static final String ATTR_NAME = "name";
- private static final String ATTR_PATH = "path";
-
- private static final File DEVICE_ROOT = new File("/");
-
- // @GuardedBy("sCache")
- private static HashMap sCache = new HashMap();
-
- private PathStrategy mStrategy;
-
- /**
- * The default FileProvider implementation does not need to be initialized. If you want to
- * override this method, you must provide your own subclass of FileProvider.
- */
- @Override
- public boolean onCreate() {
- return true;
- }
-
- /**
- * After the FileProvider is instantiated, this method is called to provide the system with
- * information about the provider.
- *
- * @param context A {@link Context} for the current component.
- * @param info A {@link ProviderInfo} for the new provider.
- */
- @Override
- public void attachInfo(Context context, ProviderInfo info) {
- super.attachInfo(context, info);
-
- // Sanity check our security
- if (info.exported) {
- throw new SecurityException("Provider must not be exported");
- }
- if (!info.grantUriPermissions) {
- throw new SecurityException("Provider must grant uri permissions");
- }
-
- mStrategy = getPathStrategy(context, info.authority);
- }
-
- /**
- * Return a content URI for a given {@link File}. Specific temporary
- * permissions for the content URI can be set with
- * {@link Context#grantUriPermission(String, Uri, int)}, or added
- * to an {@link Intent} by calling {@link Intent#setData(Uri) setData()} and then
- * {@link Intent#setFlags(int) setFlags()}; in both cases, the applicable flags are
- * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and
- * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}. A FileProvider can only return a
- * content
{@link Uri} for file paths defined in their <paths>
- * meta-data element. See the Class Overview for more information.
- *
- * @param context A {@link Context} for the current component.
- * @param authority The authority of a {@link FileProvider} defined in a
- * {@code <provider>} element in your app's manifest.
- * @param file A {@link File} pointing to the filename for which you want a
- * content
{@link Uri}.
- * @return A content URI for the file.
- * @throws IllegalArgumentException When the given {@link File} is outside
- * the paths supported by the provider.
- */
- public static Uri getUriForFile(Context context, String authority, File file) {
- final PathStrategy strategy = getPathStrategy(context, authority);
- return strategy.getUriForFile(file);
- }
-
- /**
- * Use a content URI returned by
- * {@link #getUriForFile(Context, String, File) getUriForFile()} to get information about a file
- * managed by the FileProvider.
- * FileProvider reports the column names defined in {@link android.provider.OpenableColumns}:
- *
- * {@link android.provider.OpenableColumns#DISPLAY_NAME}
- * {@link android.provider.OpenableColumns#SIZE}
- *
- * For more information, see
- * {@link ContentProvider#query(Uri, String[], String, String[], String)
- * ContentProvider.query()}.
- *
- * @param uri A content URI returned by {@link #getUriForFile}.
- * @param projection The list of columns to put into the {@link Cursor}. If null all columns are
- * included.
- * @param selection Selection criteria to apply. If null then all data that matches the content
- * URI is returned.
- * @param selectionArgs An array of {@link java.lang.String}, containing arguments to bind to
- * the selection parameter. The query method scans selection from left to
- * right and iterates through selectionArgs , replacing the current "?" character in
- * selection with the value at the current position in selectionArgs . The
- * values are bound to selection as {@link java.lang.String} values.
- * @param sortOrder A {@link java.lang.String} containing the column name(s) on which to sort
- * the resulting {@link Cursor}.
- * @return A {@link Cursor} containing the results of the query.
- *
- */
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
- // ContentProvider has already checked granted permissions
- final File file = mStrategy.getFileForUri(uri);
-
- if (projection == null) {
- projection = COLUMNS;
- }
-
- String[] cols = new String[projection.length];
- Object[] values = new Object[projection.length];
- int i = 0;
- for (String col : projection) {
- if (OpenableColumns.DISPLAY_NAME.equals(col)) {
- cols[i] = OpenableColumns.DISPLAY_NAME;
- values[i++] = file.getName();
- } else if (OpenableColumns.SIZE.equals(col)) {
- cols[i] = OpenableColumns.SIZE;
- values[i++] = file.length();
- }
- }
-
- cols = copyOf(cols, i);
- values = copyOf(values, i);
-
- final MatrixCursor cursor = new MatrixCursor(cols, 1);
- cursor.addRow(values);
- return cursor;
- }
-
- /**
- * Returns the MIME type of a content URI returned by
- * {@link #getUriForFile(Context, String, File) getUriForFile()}.
- *
- * @param uri A content URI returned by
- * {@link #getUriForFile(Context, String, File) getUriForFile()}.
- * @return If the associated file has an extension, the MIME type associated with that
- * extension; otherwise application/octet-stream
.
- */
- @Override
- public String getType(Uri uri) {
- // ContentProvider has already checked granted permissions
- final File file = mStrategy.getFileForUri(uri);
-
- final int lastDot = file.getName().lastIndexOf('.');
- if (lastDot >= 0) {
- final String extension = file.getName().substring(lastDot + 1);
- final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
- if (mime != null) {
- return mime;
- }
- }
-
- return "application/octet-stream";
- }
-
- /**
- * By default, this method throws an {@link java.lang.UnsupportedOperationException}. You must
- * subclass FileProvider if you want to provide different functionality.
- */
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- throw new UnsupportedOperationException("No external inserts");
- }
-
- /**
- * By default, this method throws an {@link java.lang.UnsupportedOperationException}. You must
- * subclass FileProvider if you want to provide different functionality.
- */
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException("No external updates");
- }
-
- /**
- * Deletes the file associated with the specified content URI, as
- * returned by {@link #getUriForFile(Context, String, File) getUriForFile()}. Notice that this
- * method does not throw an {@link java.io.IOException}; you must check its return value.
- *
- * @param uri A content URI for a file, as returned by
- * {@link #getUriForFile(Context, String, File) getUriForFile()}.
- * @param selection Ignored. Set to {@code null}.
- * @param selectionArgs Ignored. Set to {@code null}.
- * @return 1 if the delete succeeds; otherwise, 0.
- */
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- // ContentProvider has already checked granted permissions
- final File file = mStrategy.getFileForUri(uri);
- return file.delete() ? 1 : 0;
- }
-
- /**
- * By default, FileProvider automatically returns the
- * {@link ParcelFileDescriptor} for a file associated with a content://
- * {@link Uri}. To get the {@link ParcelFileDescriptor}, call
- * {@link android.content.ContentResolver#openFileDescriptor(Uri, String)
- * ContentResolver.openFileDescriptor}.
- *
- * To override this method, you must provide your own subclass of FileProvider.
- *
- * @param uri A content URI associated with a file, as returned by
- * {@link #getUriForFile(Context, String, File) getUriForFile()}.
- * @param mode Access mode for the file. May be "r" for read-only access, "rw" for read and
- * write access, or "rwt" for read and write access that truncates any existing file.
- * @return A new {@link ParcelFileDescriptor} with which you can access the file.
- */
- @Override
- public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
- // ContentProvider has already checked granted permissions
- final File file = mStrategy.getFileForUri(uri);
- final int fileMode = modeToMode(mode);
- return ParcelFileDescriptor.open(file, fileMode);
- }
-
- /**
- * Return {@link PathStrategy} for given authority, either by parsing or
- * returning from cache.
- */
- private static PathStrategy getPathStrategy(Context context, String authority) {
- PathStrategy strat;
- synchronized (sCache) {
- strat = sCache.get(authority);
- if (strat == null) {
- try {
- strat = parsePathStrategy(context, authority);
- } catch (IOException e) {
- throw new IllegalArgumentException(
- "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
- } catch (XmlPullParserException e) {
- throw new IllegalArgumentException(
- "Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
- }
- sCache.put(authority, strat);
- }
- }
- return strat;
- }
-
- /**
- * Parse and return {@link PathStrategy} for given authority as defined in
- * {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
- *
- * @see #getPathStrategy(Context, String)
- */
- private static PathStrategy parsePathStrategy(Context context, String authority)
- throws IOException, XmlPullParserException {
- final SimplePathStrategy strat = new SimplePathStrategy(authority);
-
- final ProviderInfo info = context.getPackageManager()
- .resolveContentProvider(authority, PackageManager.GET_META_DATA);
- final XmlResourceParser in = info.loadXmlMetaData(
- context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
- if (in == null) {
- throw new IllegalArgumentException(
- "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
- }
-
- int type;
- while ((type = in.next()) != END_DOCUMENT) {
- if (type == START_TAG) {
- final String tag = in.getName();
-
- final String name = in.getAttributeValue(null, ATTR_NAME);
- String path = in.getAttributeValue(null, ATTR_PATH);
-
- File target = null;
- if (TAG_ROOT_PATH.equals(tag)) {
- target = buildPath(DEVICE_ROOT, path);
- } else if (TAG_FILES_PATH.equals(tag)) {
- target = buildPath(context.getFilesDir(), path);
- } else if (TAG_CACHE_PATH.equals(tag)) {
- target = buildPath(context.getCacheDir(), path);
- } else if (TAG_EXTERNAL.equals(tag)) {
- target = buildPath(context.getExternalFilesDir(null), path);
- }
-
- if (target != null) {
- strat.addRoot(name, target);
- }
- }
- }
-
- return strat;
- }
-
- /**
- * Strategy for mapping between {@link File} and {@link Uri}.
- *
- * Strategies must be symmetric so that mapping a {@link File} to a
- * {@link Uri} and then back to a {@link File} points at the original
- * target.
- *
- * Strategies must remain consistent across app launches, and not rely on
- * dynamic state. This ensures that any generated {@link Uri} can still be
- * resolved if your process is killed and later restarted.
- *
- * @see SimplePathStrategy
- */
- interface PathStrategy {
- /**
- * Return a {@link Uri} that represents the given {@link File}.
- */
- public Uri getUriForFile(File file);
-
- /**
- * Return a {@link File} that represents the given {@link Uri}.
- */
- public File getFileForUri(Uri uri);
- }
-
- /**
- * Strategy that provides access to files living under a narrow whitelist of
- * filesystem roots. It will throw {@link SecurityException} if callers try
- * accessing files outside the configured roots.
- *
- * For example, if configured with
- * {@code addRoot("myfiles", context.getFilesDir())}, then
- * {@code context.getFileStreamPath("foo.txt")} would map to
- * {@code content://myauthority/myfiles/foo.txt}.
- */
- static class SimplePathStrategy implements PathStrategy {
- private final String mAuthority;
- private final HashMap mRoots = new HashMap();
-
- public SimplePathStrategy(String authority) {
- mAuthority = authority;
- }
-
- /**
- * Add a mapping from a name to a filesystem root. The provider only offers
- * access to files that live under configured roots.
- */
- public void addRoot(String name, File root) {
- if (TextUtils.isEmpty(name)) {
- throw new IllegalArgumentException("Name must not be empty");
- }
-
- try {
- // Resolve to canonical path to keep path checking fast
- root = root.getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalArgumentException(
- "Failed to resolve canonical path for " + root, e);
- }
-
- mRoots.put(name, root);
- }
-
- @Override
- public Uri getUriForFile(File file) {
- String path;
- try {
- path = file.getCanonicalPath();
- } catch (IOException e) {
- throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
- }
-
- // Find the most-specific root path
- Map.Entry mostSpecific = null;
- for (Map.Entry root : mRoots.entrySet()) {
- final String rootPath = root.getValue().getPath();
- if (path.startsWith(rootPath) && (mostSpecific == null
- || rootPath.length() > mostSpecific.getValue().getPath().length())) {
- mostSpecific = root;
- }
- }
-
- if (mostSpecific == null) {
- throw new IllegalArgumentException(
- "Failed to find configured root that contains " + path);
- }
-
- // Start at first char of path under root
- final String rootPath = mostSpecific.getValue().getPath();
- if (rootPath.endsWith("/")) {
- path = path.substring(rootPath.length());
- } else {
- path = path.substring(rootPath.length() + 1);
- }
-
- // Encode the tag and path separately
- path = Uri.encode(mostSpecific.getKey()) + '/' + Uri.encode(path, "/");
- return new Uri.Builder().scheme("content")
- .authority(mAuthority).encodedPath(path).build();
- }
-
- @Override
- public File getFileForUri(Uri uri) {
- String path = uri.getEncodedPath();
-
- final int splitIndex = path.indexOf('/', 1);
- final String tag = Uri.decode(path.substring(1, splitIndex));
- path = Uri.decode(path.substring(splitIndex + 1));
-
- final File root = mRoots.get(tag);
- if (root == null) {
- throw new IllegalArgumentException("Unable to find configured root for " + uri);
- }
-
- File file = new File(root, path);
- try {
- file = file.getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
- }
-
- if (!file.getPath().startsWith(root.getPath())) {
- throw new SecurityException("Resolved path jumped beyond configured root");
- }
-
- return file;
- }
- }
-
- /**
- * Copied from ContentResolver.java
- */
- private static int modeToMode(String mode) {
- int modeBits;
- if ("r".equals(mode)) {
- modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
- } else if ("w".equals(mode) || "wt".equals(mode)) {
- modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
- | ParcelFileDescriptor.MODE_CREATE
- | ParcelFileDescriptor.MODE_TRUNCATE;
- } else if ("wa".equals(mode)) {
- modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
- | ParcelFileDescriptor.MODE_CREATE
- | ParcelFileDescriptor.MODE_APPEND;
- } else if ("rw".equals(mode)) {
- modeBits = ParcelFileDescriptor.MODE_READ_WRITE
- | ParcelFileDescriptor.MODE_CREATE;
- } else if ("rwt".equals(mode)) {
- modeBits = ParcelFileDescriptor.MODE_READ_WRITE
- | ParcelFileDescriptor.MODE_CREATE
- | ParcelFileDescriptor.MODE_TRUNCATE;
- } else {
- throw new IllegalArgumentException("Invalid mode: " + mode);
- }
- return modeBits;
- }
-
- private static File buildPath(File base, String... segments) {
- File cur = base;
- for (String segment : segments) {
- if (segment != null) {
- cur = new File(cur, segment);
- }
- }
- return cur;
- }
-
- private static String[] copyOf(String[] original, int newLength) {
- final String[] result = new String[newLength];
- System.arraycopy(original, 0, result, 0, newLength);
- return result;
- }
-
- private static Object[] copyOf(Object[] original, int newLength) {
- final Object[] result = new Object[newLength];
- System.arraycopy(original, 0, result, 0, newLength);
- return result;
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/data/provider/ServiceDataProvider.java b/ServiceApp/src/org/droidplanner/services/android/data/provider/ServiceDataProvider.java
deleted file mode 100644
index 2eb3f084d0..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/data/provider/ServiceDataProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.droidplanner.services.android.data.provider;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-
-/**
- * Created by fhuya on 12/31/14.
- */
-public class ServiceDataProvider extends ContentProvider {
-
- @Override
- public boolean onCreate() {
- return false;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- return null;
- }
-
- @Override
- public String getType(Uri uri) {
- return null;
- }
-
- @Override
- public String[] getStreamTypes(Uri uri, String mimeTypeFilter){
- return null;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- return null;
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- return 0;
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- return 0;
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/activity/MainActivity.java b/ServiceApp/src/org/droidplanner/services/android/ui/activity/MainActivity.java
deleted file mode 100644
index 575f4a7feb..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/activity/MainActivity.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.droidplanner.services.android.ui.activity;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.app.ActionBarActivity;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.TextView;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.api.DroidPlannerService;
-import org.droidplanner.services.android.api.DroneAccess;
-import org.droidplanner.services.android.ui.fragment.ViewCategoryFragment;
-import org.droidplanner.services.android.utils.Utils;
-
-/**
- * User interface for the 3DR Services app.
- */
-public class MainActivity extends ActionBarActivity {
-
- private final static String TAG = MainActivity.class.getSimpleName();
-
- public static final String ACTION_SERVICE_CONNECTED = Utils.PACKAGE_NAME + ".action.SERVICE_CONNECTED";
-
- private final ServiceConnection serviceConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- droneAccess = (DroneAccess) service;
- LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(new Intent
- (ACTION_SERVICE_CONNECTED));
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- droneAccess = null;
- }
- };
-
- private DroneAccess droneAccess;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- try {
- final TextView versionInfo = (TextView) findViewById(R.id.version_info);
- versionInfo.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Unable to retrieve the version name.", e);
- }
-
- if (savedInstanceState == null) {
- final FragmentManager fm = getSupportFragmentManager();
- ViewCategoryFragment categoryViewFragment = new ViewCategoryFragment();
- fm.beginTransaction().add(R.id.fragment_container, categoryViewFragment).commit();
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
- unbindService(serviceConnection);
- }
-
- @Override
- public void onStart() {
- super.onStart();
- bindService(new Intent(getApplicationContext(), DroidPlannerService.class), serviceConnection,
- Context.BIND_AUTO_CREATE);
-
- if (droneAccess != null) {
- LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(new Intent
- (ACTION_SERVICE_CONNECTED));
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.activity_main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_learn_more:
- startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://dronekit.io/")));
- return true;
-
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- public DroneAccess getDroneAccess() {
- return droneAccess;
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/activity/TLogFileSelector.java b/ServiceApp/src/org/droidplanner/services/android/ui/activity/TLogFileSelector.java
deleted file mode 100644
index 039b3f53bc..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/activity/TLogFileSelector.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.droidplanner.services.android.ui.activity;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v7.app.ActionBarActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.o3dr.services.android.lib.data.ServiceDataContract;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.utils.file.FileUtils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * TLog file selector activity.
- */
-public class TLogFileSelector extends ActionBarActivity {
-
- private static final String TAG = TLogFileSelector.class.getSimpleName();
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_tlog_file_selector);
-
- final Context context = getApplicationContext();
-
- final Intent pickerIntent = getIntent();
- final String appId = pickerIntent.getStringExtra(ServiceDataContract.EXTRA_REQUEST_TLOG_APP_ID);
-
- //Set up an intent to send back to apps that request a file.
- final Intent resultIntent = new Intent(ServiceDataContract.ACTION_RETURN_TLOG);
-
- //Set the activity's result to null to begin with
- setResult(Activity.RESULT_CANCELED, null);
-
- final File[] tlogFiles = FileUtils.getTLogFileList(context, appId);
- final TreeMap sortedFiles = new TreeMap<>();
- for(File file : tlogFiles){
- sortedFiles.put(file.getName(), file);
- }
-
- final ArrayList sortedList = new ArrayList<>(sortedFiles.size());
- for(Map.Entry entry : sortedFiles.entrySet()){
- sortedList.add(entry.getValue());
- }
-
- final FileAdapter filesAdapter = new FileAdapter(context, sortedList);
-
- final ListView tlogListView = (ListView) findViewById(R.id.tlog_files_list);
- tlogListView.setAdapter(filesAdapter);
- tlogListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- //Get a file for the selected file name.
- File requestFile = tlogFiles[position];
- resultIntent.putExtra(ServiceDataContract.EXTRA_TLOG_ABSOLUTE_PATH, requestFile.getAbsolutePath());
- //Set the result
- setResult(Activity.RESULT_OK, resultIntent);
-
-// //Use the FileProvider to get a content URI
-// try{
-// Uri fileUri = FileProvider.getUriForFile(context, ServiceDataContract.FILE_PROVIDER_AUTHORITY,
-// requestFile);
-//
-// //Grant temporary read permission to the content URI
-// resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-//
-// //Put the uri and mime type in the result intent
-// final String mimeType = getContentResolver().getType(fileUri);
-// resultIntent.setDataAndType(fileUri, mimeType);
-//
-// //Set the result
-// setResult(Activity.RESULT_OK, resultIntent);
-// }
-// catch(IllegalArgumentException e){
-// Log.e(TAG, "The selected file can't be shared: " + requestFile.getName());
-//
-// resultIntent.setDataAndType(null, "");
-// setResult(Activity.RESULT_CANCELED, resultIntent);
-// }
-
- finish();
- }
- });
- }
-
- private static class FileAdapter extends ArrayAdapter {
-
- public FileAdapter(Context context, List objects) {
- super(context, 0, objects);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- TextView view;
- File file = getItem(position);
- if (convertView != null) {
- view = (TextView) convertView;
- } else {
- view = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.list_item_tlog_info, parent, false);
- }
-
- view.setText(file.getName());
- return view;
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/activity/UsbIntentReceiver.java b/ServiceApp/src/org/droidplanner/services/android/ui/activity/UsbIntentReceiver.java
deleted file mode 100644
index f739a36d4d..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/activity/UsbIntentReceiver.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.droidplanner.services.android.ui.activity;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-import android.support.v7.app.ActionBarActivity;
-
-import org.droidplanner.services.android.R;
-
-/**
- * Created by fhuya on 11/12/14.
- */
-public class UsbIntentReceiver extends ActionBarActivity {
-
- @Override
- public void onCreate(Bundle savedInstanceState){
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_usb_intent_receiver);
- handleIntent(getIntent());
- }
-
- @Override
- public void onNewIntent(Intent intent){
- super.onNewIntent(intent);
- handleIntent(intent);
- }
-
- private void handleIntent(Intent intent) {
- finish();
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/adapter/AppConnectionAdapter.java b/ServiceApp/src/org/droidplanner/services/android/ui/adapter/AppConnectionAdapter.java
deleted file mode 100644
index 06235c6b72..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/adapter/AppConnectionAdapter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.droidplanner.services.android.ui.adapter;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.api.DroneApi;
-import com.o3dr.services.android.lib.util.SpannableUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by fhuya on 12/10/14.
- */
-public class AppConnectionAdapter extends RecyclerView.Adapter {
-
- public static class ViewHolder extends RecyclerView.ViewHolder {
- final View containerView;
- final ImageView clientIcon;
- final TextView clientId;
- final TextView clientConnectionInfo;
- final TextView clientName;
-
- public ViewHolder(View container, ImageView clientIcon, TextView clientName, TextView clientId,
- TextView clientConnectionState) {
- super(container);
- this.containerView = container;
- this.clientIcon = clientIcon;
- this.clientId = clientId;
- this.clientConnectionInfo = clientConnectionState;
- this.clientName = clientName;
- }
- }
-
- private final Context context;
- private final List droneApiList = new ArrayList();
-
- public AppConnectionAdapter(Context context) {
- this.context = context;
- }
-
- public void refreshDroneManagerList(List list) {
- droneApiList.clear();
-
- if (list != null && !list.isEmpty()) {
- droneApiList.addAll(list);
- }
- notifyDataSetChanged();
- }
-
- @Override
- public int getItemCount() {
- return droneApiList.size();
- }
-
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_drone_info, parent,
- false);
-
- final ImageView clientIcon = (ImageView) view.findViewById(R.id.client_icon);
- final TextView clientId = (TextView) view.findViewById(R.id.client_id);
- final TextView clientConnectionInfo = (TextView) view.findViewById(R.id.client_connection_info);
- final TextView clientName = (TextView) view.findViewById(R.id.client_name);
-
- return new ViewHolder(view, clientIcon, clientName, clientId, clientConnectionInfo);
- }
-
- @Override
- public void onBindViewHolder(ViewHolder viewHolder, int position) {
- final DroneApi droneApi = droneApiList.get(position);
-
- viewHolder.containerView.setOnClickListener(null);
- viewHolder.clientName.setText("UNKNOWN");
- viewHolder.clientId.setText("AppId: unknown");
-
- final String ownerId = droneApi.getOwnerId();
- if (!TextUtils.isEmpty(ownerId)) {
- viewHolder.clientId.setText("AppId: " + ownerId);
-
- viewHolder.containerView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(ownerId);
- if(launchIntent != null)
- context.startActivity(launchIntent);
- }
- });
-
- try {
- final PackageManager pm = context.getPackageManager();
-
- final ApplicationInfo appInfo = pm.getApplicationInfo(ownerId, 0);
- Drawable appIcon = pm.getApplicationIcon(appInfo);
- viewHolder.clientIcon.setImageDrawable(appIcon);
-
- CharSequence appLabel = pm.getApplicationLabel(appInfo);
- viewHolder.clientName.setText(appLabel);
- } catch (PackageManager.NameNotFoundException e) {
- }
- }
-
- if (droneApi.isConnected()) {
- viewHolder.clientConnectionInfo.setText(SpannableUtils.normal("Status: ", SpannableUtils.color(Color
- .GREEN, "Connected")));
- } else {
- viewHolder.clientConnectionInfo.setText(SpannableUtils.normal("Status: ", SpannableUtils.color(Color.RED,
- "Disconnected")));
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/adapter/RecommendedAppsAdapter.java b/ServiceApp/src/org/droidplanner/services/android/ui/adapter/RecommendedAppsAdapter.java
deleted file mode 100644
index f9a22accc6..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/adapter/RecommendedAppsAdapter.java
+++ /dev/null
@@ -1,246 +0,0 @@
-package org.droidplanner.services.android.ui.adapter;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.support.v7.widget.RecyclerView;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import org.droidplanner.services.android.R;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import timber.log.Timber;
-
-/**
- * Loads the recommended apps data from the assets directory.
- */
-public class RecommendedAppsAdapter extends RecyclerView.Adapter {
-
- public static class ViewHolder extends RecyclerView.ViewHolder {
-
- final TextView appTitle;
- final TextView appDescription;
- final ImageView appIcon;
- final Button actionButton;
- final View actionButtonContainer;
-
- public ViewHolder(View itemView, TextView title, TextView description, ImageView icon,
- View actionButtonContainer, Button actionButton) {
- super(itemView);
- this.appTitle = title;
- this.appDescription = description;
- this.appIcon = icon;
- this.actionButton = actionButton;
- this.actionButtonContainer = actionButtonContainer;
- }
- }
-
- private static final String TAG = RecommendedAppsAdapter.class.getSimpleName();
-
- private static final String RECOMMENDED_APPS_DATA_PATH = "AppStore/recommendedApps.json";
-
- /* JSON Attributes */
- private static final String APPS_DATA_ATTRIBUTE = "apps";
- private static final String APP_ID_ATTRIBUTE = "applicationId";
- private static final String APP_NAME_ATTRIBUTE = "appName";
- private static final String APP_DESCRIPTION_ATTRIBUTE = "appDescription";
- private static final String APP_ICON_URL_ATTRIBUTE = "appIconUrl";
-
- private final Context context;
- private final JSONArray recommendedApps;
- private final WeakHashMap appsIconPerId;
-
- public RecommendedAppsAdapter(Context context) {
- this.context = context;
-
- JSONArray tempApps = null;
- try {
- final InputStream inputStream = context.getAssets().open(RECOMMENDED_APPS_DATA_PATH);
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
- final StringBuilder appsData = new StringBuilder();
-
- while (reader.ready())
- appsData.append(reader.readLine());
-
- //Parse the read data in a json object.
- JSONObject readData = new JSONObject(appsData.toString());
- tempApps = readData.optJSONArray(APPS_DATA_ATTRIBUTE);
- } catch (IOException | JSONException e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
- recommendedApps = tempApps == null ? new JSONArray() : tempApps;
- appsIconPerId = new WeakHashMap<>(recommendedApps.length());
- }
-
- @Override
- public int getItemCount() {
- return recommendedApps.length();
- }
-
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recommended_app_info,
- parent, false);
-
- final ImageView appIcon = (ImageView) view.findViewById(R.id.app_icon);
- final TextView appTitle = (TextView) view.findViewById(R.id.app_name);
- final TextView appDescription = (TextView) view.findViewById(R.id.app_description);
- final View actionButtonContainer = view.findViewById(R.id.action_button_container);
- final Button actionButton = (Button) view.findViewById(R.id.action_button);
-
- return new ViewHolder(view, appTitle, appDescription, appIcon, actionButtonContainer, actionButton);
- }
-
- @Override
- public void onBindViewHolder(ViewHolder viewHolder, int position) {
- final JSONObject appData = recommendedApps.optJSONObject(position);
- if (appData == null)
- return;
-
- viewHolder.actionButtonContainer.setVisibility(View.GONE);
-
- final String appId = appData.optString(APP_ID_ATTRIBUTE, null);
- final String appName = appData.optString(APP_NAME_ATTRIBUTE);
- final String appDescription = appData.optString(APP_DESCRIPTION_ATTRIBUTE);
- final String appIconUrl = appData.optString(APP_ICON_URL_ATTRIBUTE, null);
-
- viewHolder.appTitle.setText(appName);
- viewHolder.appDescription.setText(appDescription);
-
- if (appId != null) {
- final ImageView appImageView = viewHolder.appIcon;
- final Bitmap cachedBmp = appsIconPerId.get(appId);
- if (cachedBmp != null) {
- appImageView.setImageBitmap(cachedBmp);
- } else if (appIconUrl != null) {
- new DownloadImageTask(this.context, appId, appImageView, appsIconPerId).execute(appIconUrl);
- }
-
- viewHolder.actionButtonContainer.setVisibility(View.VISIBLE);
-
- final PackageManager pm = context.getPackageManager();
- Intent tmpIntent = pm.getLaunchIntentForPackage(appId);
- if (tmpIntent != null) {
- //The app is installed on the device.
- viewHolder.actionButton.setText(R.string.label_action_button_open);
- viewHolder.actionButton.setBackgroundResource(R.drawable.action_button_open_bg);
- } else {
- //The app is not installed on the device.
- tmpIntent = new Intent(Intent.ACTION_VIEW)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- .setData(Uri.parse("market://details?id=" + appId));
-
- if(pm.resolveActivity(tmpIntent, PackageManager.MATCH_DEFAULT_ONLY) == null){
- tmpIntent = new Intent(Intent.ACTION_VIEW)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- .setData(Uri.parse("https://play.google.com/store/apps/details?id=" + appId));
- }
-
- viewHolder.actionButton.setText(R.string.label_action_button_install);
- viewHolder.actionButton.setBackgroundResource(R.drawable.action_button_install_bg);
- }
-
- final Intent launchIntent = tmpIntent;
- viewHolder.actionButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- context.startActivity(launchIntent);
- }
- });
- }
- }
-
- private static class DownloadImageTask extends AsyncTask {
-
- private static final String ROOT_DIR = "/app_store/icons";
- private static final int BUFFER_SIZE = 1024;
-
- final ImageView bmImage;
- final String appId;
- final Map cachedMap;
- final File appIconFile;
-
- public DownloadImageTask(Context context, String appId, ImageView bmImage, Map cachedMap) {
- this.bmImage = bmImage;
- this.appId = appId;
- this.cachedMap = cachedMap;
-
- final File rootDir = new File(context.getExternalFilesDir(null), ROOT_DIR);
- if (!rootDir.exists() && !rootDir.mkdirs()) {
- Timber.w("Unable to create app store icons cache directory.");
- }
-
- this.appIconFile = new File(rootDir, appId);
- }
-
- protected Bitmap doInBackground(String... urls) {
- Bitmap mIcon11 = null;
- if (this.appIconFile.isFile() && this.appIconFile.length() > 0) {
- mIcon11 = BitmapFactory.decodeFile(this.appIconFile.getAbsolutePath());
- if (mIcon11 != null)
- return mIcon11;
- }
-
- String urlDisplay = urls[0];
- if (urlDisplay == null)
- return null;
-
- try {
- BufferedInputStream in = new BufferedInputStream(new URL(urlDisplay).openStream());
- final FileOutputStream fos = new FileOutputStream(this.appIconFile);
-
- final byte[] writeBuffer = new byte[BUFFER_SIZE];
- int byteCount;
- do {
- byteCount = in.read(writeBuffer);
- if (byteCount > -1) {
- fos.write(writeBuffer, 0, byteCount);
- fos.flush();
- }
- } while (byteCount != -1);
-
- fos.close();
-
- mIcon11 = BitmapFactory.decodeFile(this.appIconFile.getAbsolutePath());
- } catch (Exception e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
- return mIcon11;
- }
-
- protected void onPostExecute(Bitmap result) {
- if (result != null) {
- if (bmImage != null)
- bmImage.setImageBitmap(result);
-
- if (cachedMap != null)
- cachedMap.put(appId, result);
- }
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/AppConnectionsFragment.java b/ServiceApp/src/org/droidplanner/services/android/ui/fragment/AppConnectionsFragment.java
deleted file mode 100644
index c86bbf7b5a..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/AppConnectionsFragment.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.droidplanner.services.android.ui.fragment;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.api.DroidPlannerService;
-import org.droidplanner.services.android.api.DroneAccess;
-import org.droidplanner.services.android.api.DroneApi;
-import org.droidplanner.services.android.ui.activity.MainActivity;
-import org.droidplanner.services.android.ui.adapter.AppConnectionAdapter;
-
-import java.util.List;
-
-/**
- * Provide the view for all the connected/active drone apps.
- */
-public class AppConnectionsFragment extends Fragment {
-
- private final static IntentFilter intentFilter = new IntentFilter();
-
- static {
- intentFilter.addAction(MainActivity.ACTION_SERVICE_CONNECTED);
- intentFilter.addAction(DroidPlannerService.ACTION_DRONE_CREATED);
- intentFilter.addAction(DroidPlannerService.ACTION_DRONE_DESTROYED);
- }
-
- private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- switch (action) {
- case MainActivity.ACTION_SERVICE_CONNECTED:
- case DroidPlannerService.ACTION_DRONE_CREATED:
- case DroidPlannerService.ACTION_DRONE_DESTROYED:
- refreshDroneList();
- break;
- }
- }
- };
-
- private MainActivity parent;
-
- private LocalBroadcastManager lbm;
- private TextView defaultView;
- private AppConnectionAdapter appConnectionAdapter;
-
- @Override
- public void onAttach(Activity activity){
- super.onAttach(activity);
- if(!(activity instanceof MainActivity)){
- throw new IllegalStateException("Parent must be an instance of " + MainActivity.class.getName());
- }
-
- parent = (MainActivity) activity;
- }
-
- @Override
- public void onDetach(){
- super.onDetach();
- parent = null;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
- return inflater.inflate(R.layout.fragment_app_connections, container, false);
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState){
- super.onViewCreated(view, savedInstanceState);
-
- final Context context = getActivity().getApplicationContext();
- lbm = LocalBroadcastManager.getInstance(context);
-
- defaultView = (TextView) view.findViewById(R.id.default_view);
- RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.app_connections_list);
-
- //Use this setting to improve performance if you know that changes in content do not change the layout side
- // of the RecyclerView
- recyclerView.setHasFixedSize(true);
-
- //Use a grid layout manager
- final int colCount = getResources().getInteger(R.integer.connectionsColCount);
- final RecyclerView.LayoutManager gridLayoutMgr = new GridLayoutManager(context, colCount);
- recyclerView.setLayoutManager(gridLayoutMgr);
-
- appConnectionAdapter = new AppConnectionAdapter(context);
- recyclerView.setAdapter(appConnectionAdapter);
- }
-
- @Override
- public void onStart(){
- super.onStart();
- lbm.registerReceiver(broadcastReceiver, intentFilter);
- refreshDroneList();
- }
-
- @Override
- public void onStop(){
- super.onStop();
- lbm.unregisterReceiver(broadcastReceiver);
- }
-
- public void refreshDroneList(){
- if(parent == null)
- return;
-
- DroneAccess droneAccess = parent.getDroneAccess();
- if(droneAccess != null) {
- List dronesList = droneAccess.getDroneApiList();
- appConnectionAdapter.refreshDroneManagerList(dronesList);
- }
-
- boolean isEmpty = appConnectionAdapter.getItemCount() <= 0;
- defaultView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/RecommendedAppsFragment.java b/ServiceApp/src/org/droidplanner/services/android/ui/fragment/RecommendedAppsFragment.java
deleted file mode 100644
index c59cd95598..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/RecommendedAppsFragment.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.droidplanner.services.android.ui.fragment;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.ui.adapter.RecommendedAppsAdapter;
-import org.droidplanner.services.android.utils.Utils;
-
-/**
- * Provide a view of recommended apps that are compatible with 3DR Services.
- */
-public class RecommendedAppsFragment extends Fragment {
-
- public static final String ACTION_REFRESH_RECOMMENDED_APPS = Utils.PACKAGE_NAME + ".action" +
- ".REFRESH_RECOMMENDED_APPS";
-
- private static final IntentFilter intentFilter = new IntentFilter(ACTION_REFRESH_RECOMMENDED_APPS);
-
- private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- switch(intent.getAction()){
- case ACTION_REFRESH_RECOMMENDED_APPS:
- if(recommendedAppsAdapter != null)
- recommendedAppsAdapter.notifyDataSetChanged();
- break;
- }
- }
- };
- private RecommendedAppsAdapter recommendedAppsAdapter;
- private LocalBroadcastManager lbm;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
- return inflater.inflate(R.layout.fragment_recommended_apps, container, false);
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState){
- super.onViewCreated(view, savedInstanceState);
-
- final Context context = getActivity().getApplicationContext();
-
- lbm = LocalBroadcastManager.getInstance(context);
- final RecyclerView recommendedList = (RecyclerView) view.findViewById(R.id.recommended_apps_list);
-
- //Use this setting to improve performance if you know that changes in content do not change the layout side
- // of the recycler view.
- recommendedList.setHasFixedSize(true);
-
- //Use a grid layout manager
- final int colCount = getResources().getInteger(R.integer.recommendedAppsColCount);
- final RecyclerView.LayoutManager gridLayoutMgr = new GridLayoutManager(context, colCount);
- recommendedList.setLayoutManager(gridLayoutMgr);
-
- recommendedAppsAdapter = new RecommendedAppsAdapter(context);
- recommendedList.setAdapter(recommendedAppsAdapter);
- }
-
- @Override
- public void onStart(){
- super.onStart();
- recommendedAppsAdapter.notifyDataSetChanged();
- lbm.registerReceiver(broadcastReceiver, intentFilter);
- }
-
- @Override
- public void onStop(){
- super.onStop();
- lbm.unregisterReceiver(broadcastReceiver);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/ViewCategoryFragment.java b/ServiceApp/src/org/droidplanner/services/android/ui/fragment/ViewCategoryFragment.java
deleted file mode 100644
index 3c1d58b488..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/fragment/ViewCategoryFragment.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.droidplanner.services.android.ui.fragment;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.ui.widget.TabPageIndicator;
-
-/**
- * Provide a view pager to toggle between the list of active apps, and the recommended list of apps to download.
- */
-public class ViewCategoryFragment extends Fragment {
-
- private static final String EXTRA_SELECTED_CATEGORY_INDEX = "extra_selected_category_index";
-
- private ViewPager viewPager;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.fragment_connections, parent, false);
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- viewPager = (ViewPager) view.findViewById(R.id.connections_view_pager);
- viewPager.setAdapter(new ConnectionCategoryAdapter(getActivity().getApplicationContext(),
- getChildFragmentManager()));
-
- int categoryIndex = 1;
- if (savedInstanceState != null) {
- categoryIndex = savedInstanceState.getInt(EXTRA_SELECTED_CATEGORY_INDEX, categoryIndex);
- }
-
- viewPager.setCurrentItem(categoryIndex);
-
- final TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.pager_title_strip);
- tabIndicator.setViewPager(viewPager);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt(EXTRA_SELECTED_CATEGORY_INDEX, viewPager.getCurrentItem());
- }
-
- private static class ConnectionCategoryAdapter extends FragmentPagerAdapter {
-
- private final Context context;
-
- public ConnectionCategoryAdapter(Context context, FragmentManager fm) {
- super(fm);
- this.context = context;
- }
-
- @Override
- public Fragment getItem(int position) {
- switch (position) {
- case 0:
- return new AppConnectionsFragment();
-
- case 1:
- default:
- return new RecommendedAppsFragment();
- }
- }
-
- @Override
- public int getCount() {
- return 2;
- }
-
- @Override
- public CharSequence getPageTitle(int position){
- switch(position){
- case 0:
- return context.getString(R.string.label_view_category_active);
-
- case 1:
- default:
- return context.getString(R.string.label_view_category_recommended);
- }
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/widget/PageIndicator.java b/ServiceApp/src/org/droidplanner/services/android/ui/widget/PageIndicator.java
deleted file mode 100644
index f96e1320c8..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/widget/PageIndicator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 Patrik Akerfeldt
- * Copyright (C) 2011 Jake Wharton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.droidplanner.services.android.ui.widget;
-
-import android.support.v4.view.ViewPager;
-
-/**
- * A PageIndicator is responsible to show an visual indicator on the total views
- * number and the current visible view.
- */
-public interface PageIndicator extends ViewPager.OnPageChangeListener {
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- */
- void setViewPager(ViewPager view);
-
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- * @param initialPosition
- */
- void setViewPager(ViewPager view, int initialPosition);
-
- /**
- *
- * Set the current page of both the ViewPager and indicator.
- *
- *
- *
- * This must be used if you need to set the page before the
- * views are drawn on screen (e.g., default start page).
- *
- *
- * @param item
- */
- void setCurrentItem(int item);
-
- /**
- * Set a page change listener which will receive forwarded events.
- *
- * @param listener
- */
- void setOnPageChangeListener(ViewPager.OnPageChangeListener listener);
-
- /**
- * Notify the indicator that the fragment list has changed.
- */
- void notifyDataSetChanged();
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/ui/widget/TabPageIndicator.java b/ServiceApp/src/org/droidplanner/services/android/ui/widget/TabPageIndicator.java
deleted file mode 100644
index eae6c09269..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/ui/widget/TabPageIndicator.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- * Copyright (C) 2011 Jake Wharton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.droidplanner.services.android.ui.widget;
-
-import android.content.Context;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v4.view.ViewPager.OnPageChangeListener;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.HorizontalScrollView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import org.droidplanner.services.android.R;
-
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-
-/**
- * This widget implements the dynamic action bar tab behavior that can change
- * across different configurations or circumstances.
- */
-public class TabPageIndicator extends HorizontalScrollView implements PageIndicator {
- /** Title text used when no title is provided by the adapter. */
- private static final CharSequence EMPTY_TITLE = "";
-
- /**
- * Interface for a callback when the selected tab has been reselected.
- */
- public interface OnTabReselectedListener {
- /**
- * Callback when the selected tab has been reselected.
- *
- * @param position
- * Position of the current center item.
- */
- void onTabReselected(int position);
- }
-
- private Runnable mTabSelector;
-
- private final OnClickListener mTabClickListener = new OnClickListener() {
- @Override
- public void onClick(View view) {
- TabView tabView = (TabView) view;
- final int oldSelected = mViewPager.getCurrentItem();
- final int newSelected = tabView.getIndex();
- mViewPager.setCurrentItem(newSelected);
- if (oldSelected == newSelected && mTabReselectedListener != null) {
- mTabReselectedListener.onTabReselected(newSelected);
- }
- }
- };
-
- private final LinearLayout mTabLayout;
- private ViewPager mViewPager;
- private OnPageChangeListener mListener;
-
- private int mMaxTabWidth;
- private int mSelectedTabIndex;
-
- private OnTabReselectedListener mTabReselectedListener;
-
- public TabPageIndicator(Context context) {
- this(context, null);
- }
-
- public TabPageIndicator(Context context, AttributeSet attrs) {
- super(context, attrs);
- setHorizontalScrollBarEnabled(false);
-
- mTabLayout = new LinearLayout(getContext());
- addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- }
-
- public void setOnTabReselectedListener(OnTabReselectedListener listener) {
- mTabReselectedListener = listener;
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
- setFillViewport(lockedExpanded);
-
- final int childCount = mTabLayout.getChildCount();
- if (childCount > 1
- && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
- if (childCount > 2) {
- mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
- } else {
- mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
- }
- } else {
- mMaxTabWidth = -1;
- }
-
- final int oldWidth = getMeasuredWidth();
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- final int newWidth = getMeasuredWidth();
-
- if (lockedExpanded && oldWidth != newWidth) {
- // Recenter the tab display if we're at a new (scrollable) size.
- setCurrentItem(mSelectedTabIndex);
- }
- }
-
- private void animateToTab(final int position) {
- final View tabView = mTabLayout.getChildAt(position);
- if (mTabSelector != null) {
- removeCallbacks(mTabSelector);
- }
- mTabSelector = new Runnable() {
- @Override
- public void run() {
- final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
- smoothScrollTo(scrollPos, 0);
- mTabSelector = null;
- }
- };
- post(mTabSelector);
- }
-
- @Override
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (mTabSelector != null) {
- // Re-post the selector we saved
- post(mTabSelector);
- }
- }
-
- @Override
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mTabSelector != null) {
- removeCallbacks(mTabSelector);
- }
- }
-
- private void addTab(CharSequence text, int index) {
- final TabView tabView = new TabView(getContext());
- tabView.mIndex = index;
- tabView.setFocusable(true);
- tabView.setOnClickListener(mTabClickListener);
- tabView.setText(text);
-
- mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0,
- ViewGroup.LayoutParams.MATCH_PARENT, 1));
- }
-
- @Override
- public void onPageScrollStateChanged(int arg0) {
- if (mListener != null) {
- mListener.onPageScrollStateChanged(arg0);
- }
- }
-
- @Override
- public void onPageScrolled(int arg0, float arg1, int arg2) {
- if (mListener != null) {
- mListener.onPageScrolled(arg0, arg1, arg2);
- }
- }
-
- @Override
- public void onPageSelected(int arg0) {
- setCurrentItem(arg0);
- if (mListener != null) {
- mListener.onPageSelected(arg0);
- }
- }
-
- @Override
- public void setViewPager(ViewPager view) {
- if (mViewPager == view) {
- return;
- }
- if (mViewPager != null) {
- mViewPager.setOnPageChangeListener(null);
- }
- final PagerAdapter adapter = view.getAdapter();
- if (adapter == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
- mViewPager = view;
- view.setOnPageChangeListener(this);
- notifyDataSetChanged();
- }
-
- @Override
- public void notifyDataSetChanged() {
- mTabLayout.removeAllViews();
- PagerAdapter adapter = mViewPager.getAdapter();
- final int count = adapter.getCount();
- for (int i = 0; i < count; i++) {
- CharSequence title = adapter.getPageTitle(i);
- if (title == null) {
- title = EMPTY_TITLE;
- }
- addTab(title, i);
- }
- if (mSelectedTabIndex > count) {
- mSelectedTabIndex = count - 1;
- }
- setCurrentItem(mSelectedTabIndex);
- requestLayout();
- }
-
- @Override
- public void setViewPager(ViewPager view, int initialPosition) {
- setViewPager(view);
- setCurrentItem(initialPosition);
- }
-
- @Override
- public void setCurrentItem(int item) {
- if (mViewPager == null) {
- throw new IllegalStateException("ViewPager has not been bound.");
- }
- mSelectedTabIndex = item;
- mViewPager.setCurrentItem(item);
-
- final int tabCount = mTabLayout.getChildCount();
- for (int i = 0; i < tabCount; i++) {
- final View child = mTabLayout.getChildAt(i);
- final boolean isSelected = (i == item);
- child.setSelected(isSelected);
- if (isSelected) {
- animateToTab(item);
- }
- }
- }
-
- @Override
- public void setOnPageChangeListener(OnPageChangeListener listener) {
- mListener = listener;
- }
-
- private class TabView extends TextView {
- private int mIndex;
-
- public TabView(Context context) {
- super(context, null, R.attr.vpiTabPageIndicatorStyle);
- }
-
- @Override
- public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- // Re-measure if we went beyond our maximum size.
- if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
- super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth, MeasureSpec.EXACTLY),
- heightMeasureSpec);
- }
- }
-
- public int getIndex() {
- return mIndex;
- }
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/NetworkUtils.java b/ServiceApp/src/org/droidplanner/services/android/utils/NetworkUtils.java
deleted file mode 100644
index 752be83154..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/utils/NetworkUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.droidplanner.services.android.utils;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-
-import org.droidplanner.services.android.BuildConfig;
-import org.droidplanner.services.android.core.drone.autopilot.apm.solo.SoloComp;
-
-/**
- * Created by Fredia Huya-Kouadio on 5/11/15.
- */
-public class NetworkUtils {
- /**
- * Is internet connection available. This method also returns true for the SITL build type
- * @param context
- * @return Internet connection availability.
- */
- public static boolean isNetworkAvailable(Context context) {
- if (!BuildConfig.SITL_DEBUG && isOnSololinkNetwork(context))
- return false;
-
- ConnectivityManager connectivityManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
- return activeNetworkInfo != null && activeNetworkInfo.isConnected();
- }
-
- public static String getCurrentWifiLink(Context context) {
- final WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-
- final WifiInfo connectedWifi = wifiMgr.getConnectionInfo();
- final String connectedSSID = connectedWifi == null ? null : connectedWifi.getSSID().replace("\"", "");
- return connectedSSID;
- }
-
- public static boolean isOnSololinkNetwork(Context context) {
- if (BuildConfig.SITL_DEBUG)
- return true;
-
- final String connectedSSID = getCurrentWifiLink(context);
- return isSoloNetwork(connectedSSID);
- }
-
- public static boolean isSoloNetwork(String ssid) {
- return ssid != null && ssid.startsWith(SoloComp.SOLO_LINK_WIFI_PREFIX);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/analytics/GAUtils.java b/ServiceApp/src/org/droidplanner/services/android/utils/analytics/GAUtils.java
deleted file mode 100644
index 93e761a069..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/utils/analytics/GAUtils.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.droidplanner.services.android.utils.analytics;
-
-import java.util.Map;
-
-import org.droidplanner.services.android.BuildConfig;
-import org.droidplanner.services.android.DroidPlannerServicesApp;
-import org.droidplanner.services.android.R;
-import org.droidplanner.services.android.utils.prefs.DroidPlannerPrefs;
-
-import android.content.Context;
-import android.util.Log;
-
-import com.google.android.gms.analytics.GoogleAnalytics;
-import com.google.android.gms.analytics.HitBuilders;
-import com.google.android.gms.analytics.Logger;
-import com.google.android.gms.analytics.Tracker;
-import com.o3dr.services.android.lib.drone.connection.DroneSharePrefs;
-
-/**
- * Components related to google analytics logic.
- */
-public class GAUtils {
-
- private static final String LOG_TAG = GAUtils.class.getSimpleName();
-
- // Not instantiable
- private GAUtils() {}
-
- /**
- * List the analytics categories used in the app.
- */
- public static class Category {
- /**
- * Category for measuring failsafe events.
- */
- public static final String FAILSAFE = "Failsafe";
-
- /**
- * Category for analytics related to mavlink connection events.
- */
- public static final String MAVLINK_CONNECTION = "Mavlink connection";
-
- /**
- * Category for droneshare analytics
- */
- public static final String DRONESHARE = "Droneshare";
-
- /**
- * Category for mission planning, and editing.
- */
- public static final String MISSION_PLANNING = "Mission planning";
-
- }
-
- /**
- * List the custom dimension used in the app.
- */
- public static class CustomDimension {
- /**
- * Custom dimension used to report the used mavlink connection type.
- */
- public static final int MAVLINK_CONNECTION_TYPE = 1;
-
- /**
- * Custom dimension used to report whether the user has a droneshare
- * account.
- */
- public static final int DRONESHARE_ACTIVE = 2;
- }
-
- /**
- * Stores a reference to the google analytics app tracker.
- */
- private static Tracker sAppTracker;
-
- public static void initGATracker(DroidPlannerServicesApp app) {
- if (sAppTracker == null) {
- final Context context = app.getApplicationContext();
-
- final GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
-
- // Call is needed for now to allow dispatching of auto activity
- // reports
- // (http://stackoverflow.com/a/23256722/1088814)
- analytics.enableAutoActivityReports(app);
-
- analytics.setAppOptOut(!new DroidPlannerPrefs(context).isUsageStatisticsEnabled());
-
- // If we're in debug mode, set log level to verbose.
- if (BuildConfig.DEBUG) {
- analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
- }
-
- sAppTracker = analytics.newTracker(R.xml.google_analytics_tracker);
- }
- }
-
- public static void startNewSession(DroneSharePrefs prefs) {
- final boolean isDroneShareUser = prefs != null && prefs.isEnabled() && prefs.areLoginCredentialsSet();
-
- sendHit(new HitBuilders.AppViewBuilder()
- .setNewSession()
- .setCustomDimension(CustomDimension.DRONESHARE_ACTIVE,
- String.valueOf(isDroneShareUser)).build());
- }
-
- public static void sendEvent(HitBuilders.EventBuilder eventBuilder) {
- if (eventBuilder != null) {
- sendHit(eventBuilder.build());
- }
- }
-
- public static void sendEvent(HitBuilders.SocialBuilder socialBuilder){
- if(socialBuilder != null){
- sendHit(socialBuilder.build());
- }
- }
-
- public static void sendTiming(HitBuilders.TimingBuilder timingBuilder) {
- if (timingBuilder != null) {
- sendHit(timingBuilder.build());
- }
- }
-
- private static void sendHit(Map hitParams) {
- if (sAppTracker == null) {
- Log.w(LOG_TAG, "Google Analytics tracker is not initialized.");
- return;
- }
-
- sAppTracker.send(hitParams);
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/apps/AppsUpdateReceiver.java b/ServiceApp/src/org/droidplanner/services/android/utils/apps/AppsUpdateReceiver.java
deleted file mode 100644
index b2884f5fbc..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/utils/apps/AppsUpdateReceiver.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.droidplanner.services.android.utils.apps;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.support.v4.content.LocalBroadcastManager;
-
-import org.droidplanner.services.android.ui.fragment.RecommendedAppsFragment;
-
-/**
- * Created by Fredia Huya-Kouadio on 2/5/15.
- */
-public class AppsUpdateReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- LocalBroadcastManager.getInstance(context)
- .sendBroadcast(new Intent(RecommendedAppsFragment.ACTION_REFRESH_RECOMMENDED_APPS));
- }
-}
diff --git a/ServiceApp/src/org/droidplanner/services/android/utils/prefs/DroidPlannerPrefs.java b/ServiceApp/src/org/droidplanner/services/android/utils/prefs/DroidPlannerPrefs.java
deleted file mode 100644
index 7fc938ff2d..0000000000
--- a/ServiceApp/src/org/droidplanner/services/android/utils/prefs/DroidPlannerPrefs.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.droidplanner.services.android.utils.prefs;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-
-import org.droidplanner.services.android.core.drone.profiles.VehicleProfile;
-import org.droidplanner.services.android.core.drone.variables.StreamRates.Rates;
-import org.droidplanner.services.android.core.firmware.FirmwareType;
-import org.droidplanner.services.android.utils.file.IO.VehicleProfileReader;
-
-/**
- * Provides structured access to 3DR Services preferences
- *
- * Over time it might be good to move the various places that are doing
- * prefs.getFoo(blah, default) here - to collect prefs in one place and avoid
- * duplicating string constants (which tend to become stale as code evolves).
- * This is called the DRY (don't repeat yourself) principle of software
- * development.
- */
-public class DroidPlannerPrefs implements org.droidplanner.services.android.core.drone.Preferences {
-
- public static final int DEFAULT_STREAM_RATE = 2; //Hz
-
- private final SharedPreferences prefs;
- private final Context context;
-
- public DroidPlannerPrefs(Context context) {
- this.context = context;
- prefs = PreferenceManager.getDefaultSharedPreferences(context);
- }
-
- @Override
- public VehicleProfile loadVehicleProfile(FirmwareType firmwareType) {
- return VehicleProfileReader.load(context, firmwareType);
- }
-
- @Override
- public Rates getRates() {
- return new Rates(DEFAULT_STREAM_RATE);
- }
-
- /**
- * @return true if google analytics reporting is enabled.
- */
- public boolean isUsageStatisticsEnabled() {
- return prefs.getBoolean("pref_usage_statistics", true);
- }
-
-}
diff --git a/ServiceApp/src/org/droidplanner/services/package-info.java b/ServiceApp/src/org/droidplanner/services/package-info.java
deleted file mode 100644
index 8019ccdd18..0000000000
--- a/ServiceApp/src/org/droidplanner/services/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Contains all the android specific functionality and user interface for the DroidPlanner
- * application.
- */
-package org.droidplanner.services;
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 3dc9ef094d..7ff2c5d981 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,8 +3,6 @@ buildscript {
ext {
play_services_version = '8.4.0'
- support_lib_version = '23.1.1'
- okhttp_version = '2.5.0'
android_build_sdk_version = 23
android_build_tools_version = '23.0.2'
@@ -14,13 +12,10 @@ buildscript {
repositories {
jcenter()
- maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
- classpath 'io.fabric.tools:gradle:1.21.2'
//Dexcount gradle plugin
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.4'
@@ -74,6 +69,22 @@ def getGitShortHash(){
}
}
+def getMavenUsername(){
+ return hasProperty('COM_O3DR_MAVEN_USERNAME') ? COM_O3DR_MAVEN_USERNAME : ''
+}
+
+def getMavenApiKey(){
+ return hasProperty('COM_O3DR_MAVEN_APIKEY') ? COM_O3DR_MAVEN_APIKEY : ''
+}
+
+def getMavenRepo(){
+ return hasProperty('COM_O3DR_MAVEN_REPO') ? COM_O3DR_MAVEN_REPO : ''
+}
+
+def getMavenRepoUrl(){
+ return hasProperty('COM_O3DR_MAVEN_REPO_URL') ? COM_O3DR_MAVEN_REPO_URL : 'https://dl.bintray.com/3d-robotics/maven'
+}
+
/**
* Improve build server performance by allowing disabling of pre-dexing
* (see http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.)
@@ -94,6 +105,13 @@ subprojects {
allprojects {
repositories {
jcenter()
- maven { url 'https://maven.fabric.io/public' }
+
+ maven {
+ url getMavenRepoUrl()
+ credentials {
+ username getMavenUsername()
+ password getMavenApiKey()
+ }
+ }
}
}
\ No newline at end of file
diff --git a/dependencyLibs/Mavlink/build.gradle b/dependencyLibs/Mavlink/build.gradle
index 57c9870f6e..be2042cef7 100644
--- a/dependencyLibs/Mavlink/build.gradle
+++ b/dependencyLibs/Mavlink/build.gradle
@@ -11,7 +11,7 @@ sourceSets {
}
jar {
- destinationDir (new File("${rootDir}/../dronekit-android/ClientLib/libs"))
+ destinationDir (new File("${rootDir}/ClientLib/libs"))
}
dependencies {
diff --git a/dependencyLibs/Mavlink/src/com/MAVLink/Messages/MAVLinkMessage.java b/dependencyLibs/Mavlink/src/com/MAVLink/Messages/MAVLinkMessage.java
index 9ed061eb7b..37c35b406f 100644
--- a/dependencyLibs/Mavlink/src/com/MAVLink/Messages/MAVLinkMessage.java
+++ b/dependencyLibs/Mavlink/src/com/MAVLink/Messages/MAVLinkMessage.java
@@ -6,14 +6,14 @@
package com.MAVLink.Messages;
-import java.io.Serializable;
-
import com.MAVLink.MAVLinkPacket;
+import java.io.Serializable;
+
public abstract class MAVLinkMessage implements Serializable {
private static final long serialVersionUID = -7754622750478538539L;
// The MAVLink message classes have been changed to implement Serializable,
- // this way is possible to pass a mavlink message trought the Service-Acctivity interface
+ // this way is possible to pass a mavlink message through the Service-Activity interface
/**
* Simply a common interface for all MAVLink Messages
diff --git a/dependencyLibs/usb-serial-for-android/.gitignore b/dependencyLibs/usb-serial-for-android/.gitignore
deleted file mode 100644
index bde91e9b3b..0000000000
--- a/dependencyLibs/usb-serial-for-android/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-UsbSerialLibrary/bin
-UsbSerialLibrary/gen
-
-UsbSerialExamples/bin
-UsbSerialExamples/gen
-UsbSerialLibrary/dictionary.txt
-UsbSerialLibrary/local.properties
-UsbSerialLibrary/proguard-project.txt
-UsbSerialLibrary/build.xml
-
-*.iml
diff --git a/dependencyLibs/usb-serial-for-android/CHANGELOG.txt b/dependencyLibs/usb-serial-for-android/CHANGELOG.txt
deleted file mode 100644
index 8555450e60..0000000000
--- a/dependencyLibs/usb-serial-for-android/CHANGELOG.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Current Version (in development)
- * New driver: CP2102 (thanks Ducky).
- * New prober support: LUFA Virtual Serial, Leaflabs Maple, Teensyduino.
- * New driver methods: getCD, getCTS, getDSR, getDTR, setDTR, getRI, getRTS,
- setRTS.
- * API change: setBaudrate() has been removed; use setParameters().
- * API change: open() no longer implicitly sets the baud rate. Clients should
- call setParameters() immediately after open(), when necessary.
- * Library version is available in `com.hoho.android.usbserial.BuildInfo`.
-
-v0.1.0 (2012-10-12)
- * New driver: CdcAcmSerialDriver.
- * Better tuned read and write buffer sizes.
-
-v0.0.1 (2011-12-28)
- * Initial release.
diff --git a/dependencyLibs/usb-serial-for-android/LICENSE.txt b/dependencyLibs/usb-serial-for-android/LICENSE.txt
deleted file mode 100644
index 65c5ca88a6..0000000000
--- a/dependencyLibs/usb-serial-for-android/LICENSE.txt
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/dependencyLibs/usb-serial-for-android/README.md b/dependencyLibs/usb-serial-for-android/README.md
deleted file mode 100644
index 3b7338c3bf..0000000000
--- a/dependencyLibs/usb-serial-for-android/README.md
+++ /dev/null
@@ -1,96 +0,0 @@
-# usb-serial-for-android
-
-This is a driver library for communication with Arduinos and other USB serial hardware on
-Android, using the
-[Android USB Host API](http://developer.android.com/guide/topics/connectivity/usb/host.html)
-available on Android 3.1+.
-
-No root access, ADK, or special kernel drivers are required; all drivers are implemented in
-Java. You get a raw serial port with `read()`, `write()`, and other basic
-functions for use with your own protocols.
-
-* **Homepage**: https://github.com/mik3y/usb-serial-for-android
-* **Google group**: http://groups.google.com/group/usb-serial-for-android
-* **Latest release**: v0.1.0 (November 13, 2012, see [CHANGELOG](https://github.com/mik3y/usb-serial-for-android/blob/master/CHANGELOG.txt))
-
-## Quick Start
-
-**1.** Download [usb-serial-for-android-v010.jar](http://usb-serial-for-android.googlecode.com/files/usb-serial-for-android-v010.jar)
-
-**2.** Copy the jar to your Android project's `libs/` directory. (See [Android's FAQ](http://developer.android.com/guide/faq/commontasks.html#addexternallibrary) for help).
-
-**3.** Copy [device_filter.xml](http://usb-serial-for-android.googlecode.com/git/UsbSerialExamples/res/xml/device_filter.xml) to your project's `res/xml/` directory.
-
-**4.** Configure your `AndroidManifest.xml` to notify your app when a device is attached (see [Android USB Host documentation](http://developer.android.com/guide/topics/connectivity/usb/host.html#discovering-d) for help).
-
-```xml
-
-
-
-
-
-
-```
-
-**5.** Use it! Example code snippet:
-
-```java
-// Get UsbManager from Android.
-UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
-
-// Find the first available driver.
-UsbSerialDriver driver = UsbSerialProber.acquire(manager);
-
-if (driver != null) {
- driver.open();
- try {
- driver.setBaudRate(115200);
-
- byte buffer[] = new byte[16];
- int numBytesRead = driver.read(buffer, 1000);
- Log.d(TAG, "Read " + numBytesRead + " bytes.");
- } catch (IOException e) {
- // Deal with error.
- } finally {
- driver.close();
- }
-}
-```
-
-For a more complete example, see the
-[UsbSerialExamples project](https://github.com/mik3y/usb-serial-for-android/blob/master/UsbSerialExamples)
-in git, which is a simple application for reading and showing serial data.
-
-A [simple Arduino application](https://github.com/mik3y/usb-serial-for-android/blob/master/arduino)
-is also available which can be used for testing.
-
-## Compatible Devices
-
-* *Serial chips:* FT232R, CDC/ACM (eg Arduino Uno) and possibly others. See CompatibleSerialDevices
-* *Android phones and tablets:* Nexus 7, Motorola Xoom, and many others. See CompatibleAndroidDevices.
-
-
-## Author, License, and Copyright
-
-usb-serial-for-android is written and maintained by *mike wakerly*.
-
-This library is licensed under *LGPL Version 2.1*. Please see LICENSE.txt for the
-complete license.
-
-Copyright 2011-2012, Google Inc. All Rights Reserved.
-
-Portions of this library are based on libftdi
-(http://www.intra2net.com/en/developer/libftdi). Please see
-FtdiSerialDriver.java for more information.
-
-## Help & Discussion
-
-Please join our Google Group,
-[usb-serial-for-android](https://groups.google.com/forum/?fromgroups#!forum/usb-serial-for-android).
-
-Are you using this library? Let us know and we'll add your project to ProjectsUsingUsbSerialForAndroid.
-
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.classpath b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.classpath
deleted file mode 100644
index 51769745b2..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.gitignore b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.gitignore
deleted file mode 100644
index 9328249888..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.gitignore
+++ /dev/null
@@ -1,61 +0,0 @@
-# built application files
-*.apk
-*.ap_
-
-# files for the dex VM
-*.dex
-
-# Java class files
-*.class
-
-# generated files
-bin/
-gen/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Eclipse project files
-#.classpath
-#.project
-tmp.txt
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Intellij project files
-*.iml
-*.ipr
-*.iws
-.idea/
-
-*.pydevproject
-#.project
-.metadata
-bin/**
-tmp/**
-tmp/**/*
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-#.classpath
-.settings/
-.loadpath
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-
-#Do not ignore the versioning script
-!.externalToolBuilders/Verisoning.launch
-
-# PDT-specific
-.buildpath
-
-doc/*
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.project b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.project
deleted file mode 100644
index b8b86d8b89..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- UsbSerialLibrary
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/AndroidManifest.xml b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/AndroidManifest.xml
deleted file mode 100644
index 9355f7bcc3..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/build.gradle b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/build.gradle
deleted file mode 100644
index 6556e02983..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/build.gradle
+++ /dev/null
@@ -1,22 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion android_build_sdk_version
- buildToolsVersion android_build_tools_version
-
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
-
- // Move the tests to tests/java, tests/res, etc...
- androidTest.setRoot('test')
- }
-}
\ No newline at end of file
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/proguard.cfg b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/proguard.cfg
deleted file mode 100644
index 12dd0392c0..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/proguard.cfg
+++ /dev/null
@@ -1,36 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembernames class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembernames class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/project.properties b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/project.properties
deleted file mode 100644
index 8e4bc5fdce..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/project.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-19
-android.library=true
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/BuildInfo.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/BuildInfo.java
deleted file mode 100644
index 1f0d363650..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/BuildInfo.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.hoho.android.usbserial;
-
-/**
- * Static container of information about this library.
- */
-public final class BuildInfo {
-
- /**
- * The current version of this library. Values are of the form
- * "major.minor.micro[-suffix]". A suffix of "-pre" indicates a pre-release
- * of the version preceeding it.
- */
- public static final String VERSION = "0.2.0-pre";
-
- private BuildInfo() {
- throw new IllegalStateException("Non-instantiable class.");
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
deleted file mode 100644
index 45cc43d1ea..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbConstants;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbEndpoint;
-import android.hardware.usb.UsbInterface;
-import android.util.Log;
-import android.util.SparseArray;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * USB CDC/ACM serial driver implementation.
- *
- * @author mike wakerly (opensource@hoho.com)
- * @see Universal
- * Serial Bus Class Definitions for Communication Devices, v1.1
- */
-public class CdcAcmSerialDriver extends CommonUsbSerialDriver {
-
- private final String TAG = CdcAcmSerialDriver.class.getSimpleName();
-
- private UsbInterface mControlInterface;
- private UsbInterface mDataInterface;
-
- private UsbEndpoint mControlEndpoint;
- private UsbEndpoint mReadEndpoint;
- private UsbEndpoint mWriteEndpoint;
-
- private boolean mRts = false;
- private boolean mDtr = false;
-
- private static final int USB_RECIP_INTERFACE = 0x01;
- private static final int USB_RT_ACM = UsbConstants.USB_TYPE_CLASS | USB_RECIP_INTERFACE;
-
- private static final int SET_LINE_CODING = 0x20; // USB CDC 1.1 section 6.2
- private static final int GET_LINE_CODING = 0x21;
- private static final int SET_CONTROL_LINE_STATE = 0x22;
- private static final int SEND_BREAK = 0x23;
-
- public CdcAcmSerialDriver(UsbDevice device, UsbDeviceConnection connection) {
- super(device, connection);
- }
-
- @Override
- public void open() throws IOException {
- final int interfaceCount = mDevice.getInterfaceCount();
- Log.d(TAG, "claiming interfaces, count=" + interfaceCount);
-
- if(interfaceCount == 0){
- throw new IOException("No available usb interfaces.");
- }
-
- Log.d(TAG, "Claiming control interface.");
- mControlInterface = mDevice.getInterface(0);
- Log.d(TAG, "Control iface=" + mControlInterface);
- // class should be USB_CLASS_COMM
-
- if (!mConnection.claimInterface(mControlInterface, true)) {
- throw new IOException("Could not claim control interface.");
- }
-
- final int controlEndpointCount = mControlInterface.getEndpointCount();
- if(controlEndpointCount == 0){
- throw new IOException("No available control interface endpoints.");
- }
-
- mControlEndpoint = mControlInterface.getEndpoint(0);
- Log.d(TAG, "Control endpoint direction: " + mControlEndpoint.getDirection());
-
- Log.d(TAG, "Claiming data interface.");
- mDataInterface = mDevice.getInterface(1);
- Log.d(TAG, "data iface=" + mDataInterface);
- // class should be USB_CLASS_CDC_DATA
-
- if (!mConnection.claimInterface(mDataInterface, true)) {
- throw new IOException("Could not claim data interface.");
- }
-
- final int dataEndpointCount = mDataInterface.getEndpointCount();
- if(dataEndpointCount < 2){
- throw new IOException("No available data interface endpoints.");
- }
-
- mReadEndpoint = mDataInterface.getEndpoint(1);
- Log.d(TAG, "Read endpoint direction: " + mReadEndpoint.getDirection());
- mWriteEndpoint = mDataInterface.getEndpoint(0);
- Log.d(TAG, "Write endpoint direction: " + mWriteEndpoint.getDirection());
- }
-
- private int sendAcmControlMessage(int request, int value, byte[] buf) {
- return mConnection.controlTransfer(
- USB_RT_ACM, request, value, 0, buf, buf != null ? buf.length : 0, 5000);
- }
-
- @Override
- public void close() throws IOException {
- mConnection.close();
- }
-
- @Override
- public int read(byte[] dest, int timeoutMillis) throws IOException {
- final int numBytesRead;
- synchronized (mReadBufferLock) {
- int readAmt = Math.min(dest.length, mReadBuffer.length);
- numBytesRead = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer, readAmt,
- timeoutMillis);
- if (numBytesRead < 0) {
- // This sucks: we get -1 on timeout, not 0 as preferred.
- // We *should* use UsbRequest, except it has a bug/api oversight
- // where there is no way to determine the number of bytes read
- // in response :\ -- http://b.android.com/28023
- return 0;
- }
- System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead);
- }
- return numBytesRead;
- }
-
- @Override
- public int write(byte[] src, int timeoutMillis) throws IOException {
- // TODO(mikey): Nearly identical to FtdiSerial write. Refactor.
- int offset = 0;
-
- while (offset < src.length) {
- final int writeLength;
- final int amtWritten;
-
- synchronized (mWriteBufferLock) {
- final byte[] writeBuffer;
-
- writeLength = Math.min(src.length - offset, mWriteBuffer.length);
- if (offset == 0) {
- writeBuffer = src;
- } else {
- // bulkTransfer does not support offsets, make a copy.
- System.arraycopy(src, offset, mWriteBuffer, 0, writeLength);
- writeBuffer = mWriteBuffer;
- }
-
- amtWritten = mConnection.bulkTransfer(mWriteEndpoint, writeBuffer, writeLength,
- timeoutMillis);
- }
- if (amtWritten <= 0) {
- throw new IOException("Error writing " + writeLength
- + " bytes at offset " + offset + " length=" + src.length);
- }
-
- //Log.d(TAG, "Wrote amt=" + amtWritten + " attempted=" + writeLength);
- offset += amtWritten;
- }
- return offset;
- }
-
- @Override
- public void setParameters(int baudRate, int dataBits, int stopBits, int parity) {
- byte stopBitsByte;
- switch (stopBits) {
- case STOPBITS_1: stopBitsByte = 0; break;
- case STOPBITS_1_5: stopBitsByte = 1; break;
- case STOPBITS_2: stopBitsByte = 2; break;
- default: throw new IllegalArgumentException("Bad value for stopBits: " + stopBits);
- }
-
- byte parityBitesByte;
- switch (parity) {
- case PARITY_NONE: parityBitesByte = 0; break;
- case PARITY_ODD: parityBitesByte = 1; break;
- case PARITY_EVEN: parityBitesByte = 2; break;
- case PARITY_MARK: parityBitesByte = 3; break;
- case PARITY_SPACE: parityBitesByte = 4; break;
- default: throw new IllegalArgumentException("Bad value for parity: " + parity);
- }
-
- byte[] msg = {
- (byte) ( baudRate & 0xff),
- (byte) ((baudRate >> 8 ) & 0xff),
- (byte) ((baudRate >> 16) & 0xff),
- (byte) ((baudRate >> 24) & 0xff),
- stopBitsByte,
- parityBitesByte,
- (byte) dataBits};
- sendAcmControlMessage(SET_LINE_CODING, 0, msg);
- }
-
- @Override
- public boolean getCD() throws IOException {
- return false; // TODO
- }
-
- @Override
- public boolean getCTS() throws IOException {
- return false; // TODO
- }
-
- @Override
- public boolean getDSR() throws IOException {
- return false; // TODO
- }
-
- @Override
- public boolean getDTR() throws IOException {
- return mDtr;
- }
-
- @Override
- public void setDTR(boolean value) throws IOException {
- mDtr = value;
- setDtrRts();
- }
-
- @Override
- public boolean getRI() throws IOException {
- return false; // TODO
- }
-
- @Override
- public boolean getRTS() throws IOException {
- return mRts;
- }
-
- @Override
- public void setRTS(boolean value) throws IOException {
- mRts = value;
- setDtrRts();
- }
-
- private void setDtrRts() {
- int value = (mRts ? 0x2 : 0) | (mDtr ? 0x1 : 0);
- sendAcmControlMessage(SET_CONTROL_LINE_STATE, value, null);
- }
-
- public static SparseArray getSupportedDevices() {
- final SparseArray supportedDevices = new SparseArray(6);
- supportedDevices.put(UsbId.VENDOR_ARDUINO,
- new int[] {
- UsbId.ARDUINO_UNO,
- UsbId.ARDUINO_UNO_R3,
- UsbId.ARDUINO_MEGA_2560,
- UsbId.ARDUINO_MEGA_2560_R3,
- UsbId.ARDUINO_SERIAL_ADAPTER,
- UsbId.ARDUINO_SERIAL_ADAPTER_R3,
- UsbId.ARDUINO_MEGA_ADK,
- UsbId.ARDUINO_MEGA_ADK_R3,
- UsbId.ARDUINO_LEONARDO,
- });
- supportedDevices.put(UsbId.VENDOR_VAN_OOIJEN_TECH,
- new int[] {
- UsbId.VAN_OOIJEN_TECH_TEENSYDUINO_SERIAL,
- });
- supportedDevices.put(UsbId.VENDOR_ATMEL,
- new int[] {
- UsbId.ATMEL_LUFA_CDC_DEMO_APP,
- });
- supportedDevices.put(UsbId.VENDOR_LEAFLABS,
- new int[] {
- UsbId.LEAFLABS_MAPLE,
- });
- supportedDevices.put(UsbId.VENDOR_ARDUINO2,
- new int[] {
- UsbId.VAN_OOIJEN_TECH_TEENSYDUINO_SERIAL,
- UsbId.PIXHAWK,
- });
- return supportedDevices;
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CommonUsbSerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CommonUsbSerialDriver.java
deleted file mode 100644
index 9aff58843c..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/CommonUsbSerialDriver.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Copyright 2013 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-
-import java.io.IOException;
-
-/**
- * A base class shared by several driver implementations.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-abstract class CommonUsbSerialDriver implements UsbSerialDriver {
-
- public static final int DEFAULT_READ_BUFFER_SIZE = 16 * 1024;
- public static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024;
-
- protected final UsbDevice mDevice;
- protected final UsbDeviceConnection mConnection;
-
- protected final Object mReadBufferLock = new Object();
- protected final Object mWriteBufferLock = new Object();
-
- /** Internal read buffer. Guarded by {@link #mReadBufferLock}. */
- protected byte[] mReadBuffer;
-
- /** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */
- protected byte[] mWriteBuffer;
-
- public CommonUsbSerialDriver(UsbDevice device, UsbDeviceConnection connection) {
- mDevice = device;
- mConnection = connection;
-
- mReadBuffer = new byte[DEFAULT_READ_BUFFER_SIZE];
- mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE];
- }
-
- /**
- * Returns the currently-bound USB device.
- *
- * @return the device
- */
- public final UsbDevice getDevice() {
- return mDevice;
- }
-
- /**
- * Sets the size of the internal buffer used to exchange data with the USB
- * stack for read operations. Most users should not need to change this.
- *
- * @param bufferSize the size in bytes
- */
- public final void setReadBufferSize(int bufferSize) {
- synchronized (mReadBufferLock) {
- if (bufferSize == mReadBuffer.length) {
- return;
- }
- mReadBuffer = new byte[bufferSize];
- }
- }
-
- /**
- * Sets the size of the internal buffer used to exchange data with the USB
- * stack for write operations. Most users should not need to change this.
- *
- * @param bufferSize the size in bytes
- */
- public final void setWriteBufferSize(int bufferSize) {
- synchronized (mWriteBufferLock) {
- if (bufferSize == mWriteBuffer.length) {
- return;
- }
- mWriteBuffer = new byte[bufferSize];
- }
- }
-
- @Override
- public abstract void open() throws IOException;
-
- @Override
- public abstract void close() throws IOException;
-
- @Override
- public abstract int read(final byte[] dest, final int timeoutMillis) throws IOException;
-
- @Override
- public abstract int write(final byte[] src, final int timeoutMillis) throws IOException;
-
- @Override
- public abstract void setParameters(
- int baudRate, int dataBits, int stopBits, int parity) throws IOException;
-
- @Override
- public abstract boolean getCD() throws IOException;
-
- @Override
- public abstract boolean getCTS() throws IOException;
-
- @Override
- public abstract boolean getDSR() throws IOException;
-
- @Override
- public abstract boolean getDTR() throws IOException;
-
- @Override
- public abstract void setDTR(boolean value) throws IOException;
-
- @Override
- public abstract boolean getRI() throws IOException;
-
- @Override
- public abstract boolean getRTS() throws IOException;
-
- @Override
- public abstract void setRTS(boolean value) throws IOException;
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java
deleted file mode 100644
index 55760697fc..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbConstants;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbEndpoint;
-import android.hardware.usb.UsbInterface;
-import android.util.Log;
-import android.util.SparseArray;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class Cp2102SerialDriver extends CommonUsbSerialDriver {
-
- private static final String TAG = Cp2102SerialDriver.class.getSimpleName();
-
- private static final int DEFAULT_BAUD_RATE = 9600;
-
- private static final int USB_WRITE_TIMEOUT_MILLIS = 5000;
-
- /*
- * Configuration Request Types
- */
- private static final int REQTYPE_HOST_TO_DEVICE = 0x41;
-
- /*
- * Configuration Request Codes
- */
- private static final int SILABSER_IFC_ENABLE_REQUEST_CODE = 0x00;
- private static final int SILABSER_SET_BAUDDIV_REQUEST_CODE = 0x01;
- private static final int SILABSER_SET_LINE_CTL_REQUEST_CODE = 0x03;
- private static final int SILABSER_SET_MHS_REQUEST_CODE = 0x07;
- private static final int SILABSER_SET_BAUDRATE = 0x1E;
-
- /*
- * SILABSER_IFC_ENABLE_REQUEST_CODE
- */
- private static final int UART_ENABLE = 0x0001;
- private static final int UART_DISABLE = 0x0000;
-
- /*
- * SILABSER_SET_BAUDDIV_REQUEST_CODE
- */
- private static final int BAUD_RATE_GEN_FREQ = 0x384000;
-
- /*
- * SILABSER_SET_MHS_REQUEST_CODE
- */
- private static final int MCR_DTR = 0x0001;
- private static final int MCR_RTS = 0x0002;
- private static final int MCR_ALL = 0x0003;
-
- private static final int CONTROL_WRITE_DTR = 0x0100;
- private static final int CONTROL_WRITE_RTS = 0x0200;
-
- private UsbEndpoint mReadEndpoint;
- private UsbEndpoint mWriteEndpoint;
-
- public Cp2102SerialDriver(UsbDevice device, UsbDeviceConnection connection) {
- super(device, connection);
- }
-
- private int setConfigSingle(int request, int value) {
- return mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, request, value,
- 0, null, 0, USB_WRITE_TIMEOUT_MILLIS);
- }
-
- @Override
- public void open() throws IOException {
- boolean opened = false;
- try {
- for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
- UsbInterface usbIface = mDevice.getInterface(i);
- if (mConnection.claimInterface(usbIface, true)) {
- Log.d(TAG, "claimInterface " + i + " SUCCESS");
- } else {
- Log.d(TAG, "claimInterface " + i + " FAIL");
- }
- }
-
- final int interfaceCount = mDevice.getInterfaceCount();
- if(interfaceCount == 0){
- throw new IOException("No usb interfaces to access.");
- }
-
- UsbInterface dataIface = mDevice.getInterface(interfaceCount - 1);
- final int endpointCount = dataIface.getEndpointCount();
- for (int i = 0; i < endpointCount; i++) {
- UsbEndpoint ep = dataIface.getEndpoint(i);
- if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
- if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
- mReadEndpoint = ep;
- } else {
- mWriteEndpoint = ep;
- }
- }
- }
-
- setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
- setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
- setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
-// setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
- opened = true;
- } finally {
- if (!opened) {
- close();
- }
- }
- }
-
- @Override
- public void close() throws IOException {
- setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_DISABLE);
- mConnection.close();
- }
-
- @Override
- public int read(byte[] dest, int timeoutMillis) throws IOException {
- final int numBytesRead;
- synchronized (mReadBufferLock) {
- int readAmt = Math.min(dest.length, mReadBuffer.length);
- numBytesRead = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer, readAmt,
- timeoutMillis);
- if (numBytesRead < 0) {
- // This sucks: we get -1 on timeout, not 0 as preferred.
- // We *should* use UsbRequest, except it has a bug/api oversight
- // where there is no way to determine the number of bytes read
- // in response :\ -- http://b.android.com/28023
- return 0;
- }
- System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead);
- }
- return numBytesRead;
- }
-
- @Override
- public int write(byte[] src, int timeoutMillis) throws IOException {
- int offset = 0;
-
- while (offset < src.length) {
- final int writeLength;
- final int amtWritten;
-
- synchronized (mWriteBufferLock) {
- final byte[] writeBuffer;
-
- writeLength = Math.min(src.length - offset, mWriteBuffer.length);
- if (offset == 0) {
- writeBuffer = src;
- } else {
- // bulkTransfer does not support offsets, make a copy.
- System.arraycopy(src, offset, mWriteBuffer, 0, writeLength);
- writeBuffer = mWriteBuffer;
- }
-
- amtWritten = mConnection.bulkTransfer(mWriteEndpoint, writeBuffer, writeLength,
- timeoutMillis);
- }
- if (amtWritten <= 0) {
- throw new IOException("Error writing " + writeLength
- + " bytes at offset " + offset + " length=" + src.length);
- }
-
- //Log.d(TAG, "Wrote amt=" + amtWritten + " attempted=" + writeLength);
- offset += amtWritten;
- }
- return offset;
- }
-
- private void setBaudRate(int baudRate) throws IOException {
- byte[] data = new byte[] {
- (byte) ( baudRate & 0xff),
- (byte) ((baudRate >> 8 ) & 0xff),
- (byte) ((baudRate >> 16) & 0xff),
- (byte) ((baudRate >> 24) & 0xff)
- };
- int ret = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, SILABSER_SET_BAUDRATE,
- 0, 0, data, 4, USB_WRITE_TIMEOUT_MILLIS);
- if (ret < 0) {
- throw new IOException("Error setting baud rate.");
- }
- }
-
- @Override
- public void setParameters(int baudRate, int dataBits, int stopBits, int parity)
- throws IOException {
- setBaudRate(baudRate);
-
- int configDataBits = 0;
- switch (dataBits) {
- case DATABITS_5:
- configDataBits |= 0x0500;
- break;
- case DATABITS_6:
- configDataBits |= 0x0600;
- break;
- case DATABITS_7:
- configDataBits |= 0x0700;
- break;
- case DATABITS_8:
- configDataBits |= 0x0800;
- break;
- default:
- configDataBits |= 0x0800;
- break;
- }
- setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configDataBits);
-
- int configParityBits = 0; // PARITY_NONE
- switch (parity) {
- case PARITY_ODD:
- configParityBits |= 0x0010;
- break;
- case PARITY_EVEN:
- configParityBits |= 0x0020;
- break;
- }
- setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configParityBits);
-
- int configStopBits = 0;
- switch (stopBits) {
- case STOPBITS_1:
- configStopBits |= 0;
- break;
- case STOPBITS_2:
- configStopBits |= 2;
- break;
- }
- setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configStopBits);
- }
-
- @Override
- public boolean getCD() throws IOException {
- return false;
- }
-
- @Override
- public boolean getCTS() throws IOException {
- return false;
- }
-
- @Override
- public boolean getDSR() throws IOException {
- return false;
- }
-
- @Override
- public boolean getDTR() throws IOException {
- return true;
- }
-
- @Override
- public void setDTR(boolean value) throws IOException {
- }
-
- @Override
- public boolean getRI() throws IOException {
- return false;
- }
-
- @Override
- public boolean getRTS() throws IOException {
- return true;
- }
-
- @Override
- public void setRTS(boolean value) throws IOException {
- }
-
- public static SparseArray getSupportedDevices() {
- final SparseArray supportedDevices = new SparseArray(1);
- supportedDevices.put(UsbId.VENDOR_SILAB,
- new int[] {
- UsbId.SILAB_CP2102
- });
- return supportedDevices;
- }
-
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/FtdiSerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/FtdiSerialDriver.java
deleted file mode 100644
index 1bc27b2057..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/FtdiSerialDriver.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/* Copyright 2011 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbConstants;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbEndpoint;
-import android.hardware.usb.UsbInterface;
-import android.hardware.usb.UsbRequest;
-import android.util.Log;
-import android.util.SparseArray;
-
-import com.hoho.android.usbserial.util.HexDump;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * A {@link CommonUsbSerialDriver} implementation for a variety of FTDI devices
- *
- * This driver is based on
- * libftdi , and is
- * copyright and subject to the following terms:
- *
- *
- * Copyright (C) 2003 by Intra2net AG
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation;
- *
- * opensource@intra2net.com
- * http://www.intra2net.com/en/developer/libftdi
- *
- *
- *
- *
- * Some FTDI devices have not been tested; see later listing of supported and
- * unsupported devices. Devices listed as "supported" support the following
- * features:
- *
- * Read and write of serial data (see {@link #read(byte[], int)} and
- * {@link #write(byte[], int)}.
- * Setting baud rate (see {@link #setBaudRate(int)}).
- *
- *
- *
- * Supported and tested devices:
- *
- * {@value DeviceType#TYPE_R}
- *
- *
- *
- * Unsupported but possibly working devices (please contact the author with
- * feedback or patches):
- *
- * {@value DeviceType#TYPE_2232C}
- * {@value DeviceType#TYPE_2232H}
- * {@value DeviceType#TYPE_4232H}
- * {@value DeviceType#TYPE_AM}
- * {@value DeviceType#TYPE_BM}
- *
- *
- *
- * @author mike wakerly (opensource@hoho.com)
- * @see USB Serial
- * for Android project page
- * @see FTDI Homepage
- * @see libftdi
- */
-public class FtdiSerialDriver extends CommonUsbSerialDriver {
-
- public static final int USB_TYPE_STANDARD = 0x00 << 5;
- public static final int USB_TYPE_CLASS = 0x00 << 5;
- public static final int USB_TYPE_VENDOR = 0x00 << 5;
- public static final int USB_TYPE_RESERVED = 0x00 << 5;
-
- public static final int USB_RECIP_DEVICE = 0x00;
- public static final int USB_RECIP_INTERFACE = 0x01;
- public static final int USB_RECIP_ENDPOINT = 0x02;
- public static final int USB_RECIP_OTHER = 0x03;
-
- public static final int USB_ENDPOINT_IN = 0x80;
- public static final int USB_ENDPOINT_OUT = 0x00;
-
- public static final int USB_WRITE_TIMEOUT_MILLIS = 5000;
- public static final int USB_READ_TIMEOUT_MILLIS = 5000;
-
- // From ftdi.h
- /**
- * Reset the port.
- */
- private static final int SIO_RESET_REQUEST = 0;
-
- /**
- * Set the modem control register.
- */
- private static final int SIO_MODEM_CTRL_REQUEST = 1;
-
- /**
- * Set flow control register.
- */
- private static final int SIO_SET_FLOW_CTRL_REQUEST = 2;
-
- /**
- * Set baud rate.
- */
- private static final int SIO_SET_BAUD_RATE_REQUEST = 3;
-
- /**
- * Set the data characteristics of the port.
- */
- private static final int SIO_SET_DATA_REQUEST = 4;
-
- private static final int SIO_RESET_SIO = 0;
-
- public static final int FTDI_DEVICE_OUT_REQTYPE =
- UsbConstants.USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT;
-
- public static final int FTDI_DEVICE_IN_REQTYPE =
- UsbConstants.USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN;
-
- /**
- * Length of the modem status header, transmitted with every read.
- */
- private static final int MODEM_STATUS_HEADER_LENGTH = 2;
-
- private final String TAG = FtdiSerialDriver.class.getSimpleName();
-
- private DeviceType mType;
-
- /**
- * FTDI chip types.
- */
- private static enum DeviceType {
- TYPE_BM, TYPE_AM, TYPE_2232C, TYPE_R, TYPE_2232H, TYPE_4232H
- }
-
- private int mInterface = 0; /* INTERFACE_ANY */
-
- private int mMaxPacketSize = 64; // TODO(mikey): detect
-
- /**
- * Due to http://b.android.com/28023 , we cannot use UsbRequest async reads
- * since it gives no indication of number of bytes read. Set this to
- * {@code true} on platforms where it is fixed.
- */
- private static final boolean ENABLE_ASYNC_READS = false;
-
- /**
- * Filter FTDI status bytes from buffer
- * @param src The source buffer (which contains status bytes)
- * @param dest The destination buffer to write the status bytes into (can be src)
- * @param totalBytesRead Number of bytes read to src
- * @param maxPacketSize The USB endpoint max packet size
- * @return The number of payload bytes
- */
- private final int filterStatusBytes(byte[] src, byte[] dest, int totalBytesRead, int maxPacketSize) {
- final int packetsCount = totalBytesRead / maxPacketSize + 1;
- for (int packetIdx = 0; packetIdx < packetsCount; ++packetIdx) {
- final int count = (packetIdx == (packetsCount - 1))
- ? (totalBytesRead % maxPacketSize) - MODEM_STATUS_HEADER_LENGTH
- : maxPacketSize - MODEM_STATUS_HEADER_LENGTH;
- if (count > 0) {
- System.arraycopy(src,
- packetIdx * maxPacketSize + MODEM_STATUS_HEADER_LENGTH,
- dest,
- packetIdx * (maxPacketSize - MODEM_STATUS_HEADER_LENGTH),
- count);
- }
- }
-
- return totalBytesRead - (packetsCount * 2);
- }
-
- /**
- * Constructor.
- *
- * @param usbDevice the {@link UsbDevice} to use
- * @param usbConnection the {@link UsbDeviceConnection} to use
- * @throws UsbSerialRuntimeException if the given device is incompatible
- * with this driver
- */
- public FtdiSerialDriver(UsbDevice usbDevice, UsbDeviceConnection usbConnection) {
- super(usbDevice, usbConnection);
- mType = null;
- }
-
- public void reset() throws IOException {
- int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE, SIO_RESET_REQUEST,
- SIO_RESET_SIO, 0 /* index */, null, 0, USB_WRITE_TIMEOUT_MILLIS);
- if (result != 0) {
- throw new IOException("Reset failed: result=" + result);
- }
-
- // TODO(mikey): autodetect.
- mType = DeviceType.TYPE_R;
- }
-
- @Override
- public void open() throws IOException {
- boolean opened = false;
- try {
- for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
- if (mConnection.claimInterface(mDevice.getInterface(i), true)) {
- Log.d(TAG, "claimInterface " + i + " SUCCESS");
- } else {
- throw new IOException("Error claiming interface " + i);
- }
- }
- reset();
- opened = true;
- } finally {
- if (!opened) {
- close();
- }
- }
- }
-
- @Override
- public void close() {
- mConnection.close();
- }
-
- @Override
- public int read(byte[] dest, int timeoutMillis) throws IOException {
- final int interfaceCount = mDevice.getInterfaceCount();
- if(interfaceCount == 0)
- throw new IOException("No available usb interface.");
-
- final UsbInterface usbInterface = mDevice.getInterface(0);
- final int endpointCount = usbInterface.getEndpointCount();
- if(endpointCount == 0)
- throw new IOException("No available usb endpoint.");
-
- final UsbEndpoint endpoint = usbInterface.getEndpoint(0);
-
- if (ENABLE_ASYNC_READS) {
- final int readAmt;
- synchronized (mReadBufferLock) {
- // mReadBuffer is only used for maximum read size.
- readAmt = Math.min(dest.length, mReadBuffer.length);
- }
-
- final UsbRequest request = new UsbRequest();
- request.initialize(mConnection, endpoint);
-
- final ByteBuffer buf = ByteBuffer.wrap(dest);
- if (!request.queue(buf, readAmt)) {
- throw new IOException("Error queueing request.");
- }
-
- final UsbRequest response = mConnection.requestWait();
- if (response == null) {
- throw new IOException("Null response");
- }
-
- final int payloadBytesRead = buf.position() - MODEM_STATUS_HEADER_LENGTH;
- if (payloadBytesRead > 0) {
- Log.d(TAG, HexDump.dumpHexString(dest, 0, Math.min(32, dest.length)));
- return payloadBytesRead;
- } else {
- return 0;
- }
- } else {
- final int totalBytesRead;
-
- synchronized (mReadBufferLock) {
- final int readAmt = Math.min(dest.length, mReadBuffer.length);
- totalBytesRead = mConnection.bulkTransfer(endpoint, mReadBuffer,
- readAmt, timeoutMillis);
-
- if (totalBytesRead < MODEM_STATUS_HEADER_LENGTH) {
- throw new IOException("Expected at least " + MODEM_STATUS_HEADER_LENGTH + " bytes");
- }
-
- return filterStatusBytes(mReadBuffer, dest, totalBytesRead, endpoint.getMaxPacketSize());
- }
- }
- }
-
- @Override
- public int write(byte[] src, int timeoutMillis) throws IOException {
- final UsbEndpoint endpoint = mDevice.getInterface(0).getEndpoint(1);
- int offset = 0;
-
- while (offset < src.length) {
- final int writeLength;
- final int amtWritten;
-
- synchronized (mWriteBufferLock) {
- final byte[] writeBuffer;
-
- writeLength = Math.min(src.length - offset, mWriteBuffer.length);
- if (offset == 0) {
- writeBuffer = src;
- } else {
- // bulkTransfer does not support offsets, make a copy.
- System.arraycopy(src, offset, mWriteBuffer, 0, writeLength);
- writeBuffer = mWriteBuffer;
- }
-
- amtWritten = mConnection.bulkTransfer(endpoint, writeBuffer, writeLength,
- timeoutMillis);
- }
-
- if (amtWritten <= 0) {
- throw new IOException("Error writing " + writeLength
- + " bytes at offset " + offset + " length=" + src.length);
- }
-
- //Log.d(TAG, "Wrote amtWritten=" + amtWritten + " attempted=" + writeLength);
- offset += amtWritten;
- }
- return offset;
- }
-
- private int setBaudRate(int baudRate) throws IOException {
- long[] vals = convertBaudrate(baudRate);
- long actualBaudrate = vals[0];
- long index = vals[1];
- long value = vals[2];
- int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE,
- SIO_SET_BAUD_RATE_REQUEST, (int) value, (int) index,
- null, 0, USB_WRITE_TIMEOUT_MILLIS);
- if (result != 0) {
- throw new IOException("Setting baudrate failed: result=" + result);
- }
- return (int) actualBaudrate;
- }
-
- @Override
- public void setParameters(int baudRate, int dataBits, int stopBits, int parity)
- throws IOException {
- setBaudRate(baudRate);
-
- int config = dataBits;
-
- switch (parity) {
- case PARITY_NONE:
- config |= (0x00 << 8);
- break;
- case PARITY_ODD:
- config |= (0x01 << 8);
- break;
- case PARITY_EVEN:
- config |= (0x02 << 8);
- break;
- case PARITY_MARK:
- config |= (0x03 << 8);
- break;
- case PARITY_SPACE:
- config |= (0x04 << 8);
- break;
- default:
- throw new IllegalArgumentException("Unknown parity value: " + parity);
- }
-
- switch (stopBits) {
- case STOPBITS_1:
- config |= (0x00 << 11);
- break;
- case STOPBITS_1_5:
- config |= (0x01 << 11);
- break;
- case STOPBITS_2:
- config |= (0x02 << 11);
- break;
- default:
- throw new IllegalArgumentException("Unknown stopBits value: " + stopBits);
- }
-
- int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE,
- SIO_SET_DATA_REQUEST, config, 0 /* index */,
- null, 0, USB_WRITE_TIMEOUT_MILLIS);
- if (result != 0) {
- throw new IOException("Setting parameters failed: result=" + result);
- }
- }
-
- private long[] convertBaudrate(int baudrate) {
- // TODO(mikey): Braindead transcription of libfti method. Clean up,
- // using more idiomatic Java where possible.
- int divisor = 24000000 / baudrate;
- int bestDivisor = 0;
- int bestBaud = 0;
- int bestBaudDiff = 0;
- int fracCode[] = {
- 0, 3, 2, 4, 1, 5, 6, 7
- };
-
- for (int i = 0; i < 2; i++) {
- int tryDivisor = divisor + i;
- int baudEstimate;
- int baudDiff;
-
- if (tryDivisor <= 8) {
- // Round up to minimum supported divisor
- tryDivisor = 8;
- } else if (mType != DeviceType.TYPE_AM && tryDivisor < 12) {
- // BM doesn't support divisors 9 through 11 inclusive
- tryDivisor = 12;
- } else if (divisor < 16) {
- // AM doesn't support divisors 9 through 15 inclusive
- tryDivisor = 16;
- } else {
- if (mType == DeviceType.TYPE_AM) {
- // TODO
- } else {
- if (tryDivisor > 0x1FFFF) {
- // Round down to maximum supported divisor value (for
- // BM)
- tryDivisor = 0x1FFFF;
- }
- }
- }
-
- // Get estimated baud rate (to nearest integer)
- baudEstimate = (24000000 + (tryDivisor / 2)) / tryDivisor;
-
- // Get absolute difference from requested baud rate
- if (baudEstimate < baudrate) {
- baudDiff = baudrate - baudEstimate;
- } else {
- baudDiff = baudEstimate - baudrate;
- }
-
- if (i == 0 || baudDiff < bestBaudDiff) {
- // Closest to requested baud rate so far
- bestDivisor = tryDivisor;
- bestBaud = baudEstimate;
- bestBaudDiff = baudDiff;
- if (baudDiff == 0) {
- // Spot on! No point trying
- break;
- }
- }
- }
-
- // Encode the best divisor value
- long encodedDivisor = (bestDivisor >> 3) | (fracCode[bestDivisor & 7] << 14);
- // Deal with special cases for encoded value
- if (encodedDivisor == 1) {
- encodedDivisor = 0; // 3000000 baud
- } else if (encodedDivisor == 0x4001) {
- encodedDivisor = 1; // 2000000 baud (BM only)
- }
-
- // Split into "value" and "index" values
- long value = encodedDivisor & 0xFFFF;
- long index;
- if (mType == DeviceType.TYPE_2232C || mType == DeviceType.TYPE_2232H
- || mType == DeviceType.TYPE_4232H) {
- index = (encodedDivisor >> 8) & 0xffff;
- index &= 0xFF00;
- index |= 0 /* TODO mIndex */;
- } else {
- index = (encodedDivisor >> 16) & 0xffff;
- }
-
- // Return the nearest baud rate
- return new long[] {
- bestBaud, index, value
- };
- }
-
- @Override
- public boolean getCD() throws IOException {
- return false;
- }
-
- @Override
- public boolean getCTS() throws IOException {
- return false;
- }
-
- @Override
- public boolean getDSR() throws IOException {
- return false;
- }
-
- @Override
- public boolean getDTR() throws IOException {
- return false;
- }
-
- @Override
- public void setDTR(boolean value) throws IOException {
- }
-
- @Override
- public boolean getRI() throws IOException {
- return false;
- }
-
- @Override
- public boolean getRTS() throws IOException {
- return false;
- }
-
- @Override
- public void setRTS(boolean value) throws IOException {
- }
-
- public static SparseArray getSupportedDevices() {
- final SparseArray supportedDevices = new SparseArray(1);
- supportedDevices.put(UsbId.VENDOR_FTDI,
- new int[] {
- UsbId.FTDI_FT232R,
- UsbId.FTDI_FT231X,
- });
- return supportedDevices;
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/ProlificSerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/ProlificSerialDriver.java
deleted file mode 100644
index 06406b43f8..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/ProlificSerialDriver.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: https://github.com/mik3y/usb-serial-for-android
- */
-
-/*
- * Added to DroidPlanner
- * by Eric Day
- *
- * Ported to usb-serial-for-android
- * by Felix Hädicke
- *
- * Based on the pyprolific driver written
- * by Emmanuel Blot
- * See https://github.com/eblot/pyftdi
- */
-
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbConstants;
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbEndpoint;
-import android.hardware.usb.UsbInterface;
-import android.util.Log;
-import android.util.SparseArray;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class ProlificSerialDriver extends CommonUsbSerialDriver {
-
- private final String TAG = ProlificSerialDriver.class.getSimpleName();
-
- private static final int USB_READ_TIMEOUT_MILLIS = 1000;
- private static final int USB_WRITE_TIMEOUT_MILLIS = 5000;
-
- private static final int USB_RECIP_INTERFACE = 0x01;
-
- private static final int PROLIFIC_VENDOR_READ_REQUEST = 0x01;
- private static final int PROLIFIC_VENDOR_WRITE_REQUEST = 0x01;
-
- private static final int PROLIFIC_VENDOR_OUT_REQTYPE = /*UsbConstants.USB_DIR_OUT
- |*/ UsbConstants.USB_TYPE_VENDOR;
-
- private static final int PROLIFIC_VENDOR_IN_REQTYPE = UsbConstants.USB_DIR_IN
- | UsbConstants.USB_TYPE_VENDOR;
-
- private static final int PROLIFIC_CTRL_OUT_REQTYPE = /*UsbConstants.USB_DIR_OUT
- |*/ UsbConstants.USB_TYPE_CLASS | USB_RECIP_INTERFACE;
-
- private static final int WRITE_ENDPOINT = 0x02;
- private static final int READ_ENDPOINT = 0x83;
- private static final int INTERRUPT_ENDPOINT = 0x81;
-
- private static final int FLUSH_RX_REQUEST = 0x08;
- private static final int FLUSH_TX_REQUEST = 0x09;
-
- private static final int SET_LINE_REQUEST = 0x20;
- private static final int SET_CONTROL_REQUEST = 0x22;
-
- private static final int CONTROL_DTR = 0x01;
- private static final int CONTROL_RTS = 0x02;
-
- private static final int STATUS_FLAG_CD = 0x01;
- private static final int STATUS_FLAG_DSR = 0x02;
- private static final int STATUS_FLAG_RI = 0x08;
- private static final int STATUS_FLAG_CTS = 0x80;
-
- private static final int STATUS_BUFFER_SIZE = 10;
- private static final int STATUS_BYTE_IDX = 8;
-
- private static final int DEVICE_TYPE_HX = 0;
- private static final int DEVICE_TYPE_0 = 1;
- private static final int DEVICE_TYPE_1 = 2;
-
- private int mDeviceType = DEVICE_TYPE_HX;
-
- private UsbEndpoint mReadEndpoint;
- private UsbEndpoint mWriteEndpoint;
- private UsbEndpoint mInterruptEndpoint;
-
- private int mControlLinesValue = 0;
-
- private int mBaudRate = -1, mDataBits = -1, mStopBits = -1, mParity = -1;
-
- private int mStatus = 0;
- private volatile Thread mReadStatusThread = null;
- private final Object mReadStatusThreadLock = new Object();
- boolean mStopReadStatusThread = false;
- private IOException mReadStatusException = null;
-
-
- public ProlificSerialDriver(UsbDevice device, UsbDeviceConnection connection) {
- super(device, connection);
- }
-
- public static SparseArray getSupportedDevices() {
- final SparseArray supportedDevices = new SparseArray(1);
- supportedDevices.put(UsbId.VENDOR_PROLIFIC,
- new int[] { UsbId.PROLIFIC_PL2303, });
- return supportedDevices;
- }
-
- private final byte[] inControlTransfer(int requestType, int request,
- int value, int index, int length) throws IOException {
- byte[] buffer = new byte[length];
- int result = mConnection.controlTransfer(requestType, request, value,
- index, buffer, length, USB_READ_TIMEOUT_MILLIS);
- if (result != length) {
- throw new IOException(
- String.format("ControlTransfer with value 0x%x failed: %d",
- value, result));
- }
- return buffer;
- }
-
- private final void outControlTransfer(int requestType, int request,
- int value, int index, byte[] data) throws IOException {
- int length = (data == null) ? 0 : data.length;
- int result = mConnection.controlTransfer(requestType, request, value,
- index, data, length, USB_WRITE_TIMEOUT_MILLIS);
- if (result != length) {
- throw new IOException(
- String.format("ControlTransfer with value 0x%x failed: %d",
- value, result));
- }
- }
-
- private final byte[] vendorIn(int value, int index, int length)
- throws IOException {
- return inControlTransfer(PROLIFIC_VENDOR_IN_REQTYPE,
- PROLIFIC_VENDOR_READ_REQUEST, value, index, length);
- }
-
- private final void vendorOut(int value, int index, byte[] data)
- throws IOException {
- outControlTransfer(PROLIFIC_VENDOR_OUT_REQTYPE,
- PROLIFIC_VENDOR_WRITE_REQUEST, value, index, data);
- }
-
- private void resetDevice() throws IOException {
- purgeHwBuffers(true, true);
- }
-
- private final void ctrlOut(int request, int value, int index, byte[] data)
- throws IOException {
- outControlTransfer(PROLIFIC_CTRL_OUT_REQTYPE, request, value, index,
- data);
- }
-
- private void doBlackMagic() throws IOException {
- vendorIn(0x8484, 0, 1);
- vendorOut(0x0404, 0, null);
- vendorIn(0x8484, 0, 1);
- vendorIn(0x8383, 0, 1);
- vendorIn(0x8484, 0, 1);
- vendorOut(0x0404, 1, null);
- vendorIn(0x8484, 0, 1);
- vendorIn(0x8383, 0, 1);
- vendorOut(0, 1, null);
- vendorOut(1, 0, null);
- vendorOut(2, (mDeviceType == DEVICE_TYPE_HX) ? 0x44 : 0x24, null);
- }
-
- private void setControlLines(int newControlLinesValue) throws IOException {
- ctrlOut(SET_CONTROL_REQUEST, newControlLinesValue, 0, null);
- mControlLinesValue = newControlLinesValue;
- }
-
- private final void readStatusThreadFunction() {
- try {
- while (!mStopReadStatusThread) {
- byte[] buffer = new byte[STATUS_BUFFER_SIZE];
- int readBytesCount = mConnection.bulkTransfer(mInterruptEndpoint,
- buffer,
- STATUS_BUFFER_SIZE,
- 500);
- if (readBytesCount > 0) {
- if (readBytesCount == STATUS_BUFFER_SIZE) {
- mStatus = buffer[STATUS_BYTE_IDX] & 0xff;
- } else {
- throw new IOException(
- String.format("Invalid CTS / DSR / CD / RI status buffer received, expected %d bytes, but received %d",
- STATUS_BUFFER_SIZE,
- readBytesCount));
- }
- }
- }
- } catch (IOException e) {
- mReadStatusException = e;
- }
- }
-
- private final int getStatus() throws IOException {
- if ((mReadStatusThread == null) && (mReadStatusException == null)) {
- synchronized (mReadStatusThreadLock) {
- if (mReadStatusThread == null) {
- byte[] buffer = new byte[STATUS_BUFFER_SIZE];
- int readBytes = mConnection.bulkTransfer(mInterruptEndpoint,
- buffer,
- STATUS_BUFFER_SIZE,
- 100);
- if (readBytes != STATUS_BUFFER_SIZE) {
- Log.w(TAG, "Could not read initial CTS / DSR / CD / RI status");
- } else {
- mStatus = buffer[STATUS_BYTE_IDX] & 0xff;
- }
-
- mReadStatusThread = new Thread(new Runnable() {
- @Override
- public void run() {
- readStatusThreadFunction();
- }
- });
- mReadStatusThread.setDaemon(true);
- mReadStatusThread.start();
- }
- }
- }
-
- /* throw and clear an exception which occured in the status read thread */
- IOException readStatusException = mReadStatusException;
- if (mReadStatusException != null) {
- mReadStatusException = null;
- throw readStatusException;
- }
-
- return mStatus;
- }
-
- private final boolean testStatusFlag(int flag) throws IOException {
- return ((getStatus() & flag) == flag);
- }
-
- @Override
- public void open() throws IOException {
- boolean opened = false;
- try {
- for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
- UsbInterface usbIface = mDevice.getInterface(i);
- if (mConnection.claimInterface(usbIface, true)) {
- Log.d(TAG, "claimInterface " + i + " SUCCESS");
- }
- else {
- Log.d(TAG, "claimInterface " + i + " FAIL");
- }
- }
-
- UsbInterface dataIface = mDevice.getInterface(mDevice.getInterfaceCount() - 1);
- for (int i = 0; i < dataIface.getEndpointCount(); i ++) {
- UsbEndpoint ep = dataIface.getEndpoint(i);
-
- switch (ep.getAddress()) {
- case READ_ENDPOINT:
- mReadEndpoint = ep;
- break;
-
- case WRITE_ENDPOINT:
- mWriteEndpoint = ep;
- break;
-
- case INTERRUPT_ENDPOINT:
- mInterruptEndpoint = ep;
- break;
- }
- }
-
- if (mDevice.getDeviceClass() == 0x02) {
- mDeviceType = DEVICE_TYPE_0;
- } else {
- try {
- Method getRawDescriptorsMethod
- = mConnection.getClass().getMethod("getRawDescriptors");
- byte[] rawDescriptors
- = (byte[]) getRawDescriptorsMethod.invoke(mConnection);
- byte maxPacketSize0 = rawDescriptors[7];
- if (maxPacketSize0 == 64) {
- mDeviceType = DEVICE_TYPE_HX;
- } else if ((mDevice.getDeviceClass() == 0x00)
- || (mDevice.getDeviceClass() == 0xff)) {
- mDeviceType = DEVICE_TYPE_1;
- } else {
- Log.w(TAG, "Could not detect PL2303 subtype, "
- + "Assuming that it is a HX device");
- mDeviceType = DEVICE_TYPE_HX;
- }
- } catch (NoSuchMethodException e) {
- Log.w(TAG, "Method UsbDeviceConnection.getRawDescriptors, "
- + "required for PL2303 subtype detection, not "
- + "available! Assuming that it is a HX device");
- mDeviceType = DEVICE_TYPE_HX;
- } catch (Exception e) {
- Log.e(TAG, "An unexpected exception occured while trying "
- + "to detect PL2303 subtype", e);
- }
- }
-
- setControlLines(mControlLinesValue);
- resetDevice();
-
- doBlackMagic();
- opened = true;
- } finally {
- if (!opened) {
- close();
- }
- }
- }
-
- @Override
- public void close() throws IOException {
- try {
- mStopReadStatusThread = true;
- synchronized (mReadStatusThreadLock) {
- if (mReadStatusThread != null) {
- try {
- mReadStatusThread.join();
- } catch (Exception e) {
- Log.w(TAG, "An error occured while waiting for status read thread", e);
- }
- }
- }
- resetDevice();
- } finally {
- mConnection.close();
- }
- }
-
- @Override
- public int read(byte[] dest, int timeoutMillis) throws IOException {
- final int numBytesRead;
- synchronized (mReadBufferLock) {
- int readAmt = Math.min(dest.length, mReadBuffer.length);
- numBytesRead = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer,
- readAmt, timeoutMillis);
- if (numBytesRead < 0) {
- return 0;
- }
- System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead);
- }
-
- return numBytesRead;
- }
-
- @Override
- public int write(byte[] src, int timeoutMillis) throws IOException {
- int offset = 0;
-
- while (offset < src.length) {
- final int writeLength;
- final int amtWritten;
-
- synchronized (mWriteBufferLock) {
- final byte[] writeBuffer;
-
- writeLength = Math.min(src.length - offset, mWriteBuffer.length);
- if (offset == 0) {
- writeBuffer = src;
- } else {
- // bulkTransfer does not support offsets, make a copy.
- System.arraycopy(src, offset, mWriteBuffer, 0, writeLength);
- writeBuffer = mWriteBuffer;
- }
-
- amtWritten = mConnection.bulkTransfer(mWriteEndpoint,
- writeBuffer, writeLength, timeoutMillis);
- }
-
- if (amtWritten <= 0) {
- throw new IOException("Error writing " + writeLength
- + " bytes at offset " + offset + " length="
- + src.length);
- }
-
- offset += amtWritten;
- }
- return offset;
- }
-
- @Override
- public void setParameters(int baudRate, int dataBits, int stopBits,
- int parity) throws IOException {
- if ((mBaudRate == baudRate) && (mDataBits == dataBits)
- && (mStopBits == stopBits) && (mParity == parity)) {
- // Make sure no action is performed if there is nothing to change
- return;
- }
-
- byte[] lineRequestData = new byte[7];
-
- lineRequestData[0] = (byte) (baudRate & 0xff);
- lineRequestData[1] = (byte) ((baudRate >> 8) & 0xff);
- lineRequestData[2] = (byte) ((baudRate >> 16) & 0xff);
- lineRequestData[3] = (byte) ((baudRate >> 24) & 0xff);
-
- switch (stopBits) {
- case STOPBITS_1:
- lineRequestData[4] = 0;
- break;
-
- case STOPBITS_1_5:
- lineRequestData[4] = 1;
- break;
-
- case STOPBITS_2:
- lineRequestData[4] = 2;
- break;
-
- default:
- throw new IllegalArgumentException("Unknown stopBits value: " + stopBits);
- }
-
- switch (parity) {
- case PARITY_NONE:
- lineRequestData[5] = 0;
- break;
-
- case PARITY_ODD:
- lineRequestData[5] = 1;
- break;
-
- case PARITY_MARK:
- lineRequestData[5] = 3;
- break;
-
- case PARITY_SPACE:
- lineRequestData[5] = 4;
- break;
-
- default:
- throw new IllegalArgumentException("Unknown parity value: " + parity);
- }
-
- lineRequestData[6] = (byte) dataBits;
-
- ctrlOut(SET_LINE_REQUEST, 0, 0, lineRequestData);
-
- resetDevice();
-
- mBaudRate = baudRate;
- mDataBits = dataBits;
- mStopBits = stopBits;
- mParity = parity;
- }
-
- @Override
- public boolean getCD() throws IOException {
- return testStatusFlag(STATUS_FLAG_CD);
- }
-
- @Override
- public boolean getCTS() throws IOException {
- return testStatusFlag(STATUS_FLAG_CTS);
- }
-
- @Override
- public boolean getDSR() throws IOException {
- return testStatusFlag(STATUS_FLAG_DSR);
- }
-
- @Override
- public boolean getDTR() throws IOException {
- return ((mControlLinesValue & CONTROL_DTR) == CONTROL_DTR);
- }
-
- @Override
- public void setDTR(boolean value) throws IOException {
- int newControlLinesValue;
- if (value) {
- newControlLinesValue = mControlLinesValue | CONTROL_DTR;
- } else {
- newControlLinesValue = mControlLinesValue & ~CONTROL_DTR;
- }
- setControlLines(newControlLinesValue);
- }
-
- @Override
- public boolean getRI() throws IOException {
- return testStatusFlag(STATUS_FLAG_RI);
- }
-
- @Override
- public boolean getRTS() throws IOException {
- return ((mControlLinesValue & CONTROL_RTS) == CONTROL_RTS);
- }
-
- @Override
- public void setRTS(boolean value) throws IOException {
- int newControlLinesValue;
- if (value) {
- newControlLinesValue = mControlLinesValue | CONTROL_RTS;
- } else {
- newControlLinesValue = mControlLinesValue & ~CONTROL_RTS;
- }
- setControlLines(newControlLinesValue);
- }
-
- public boolean purgeHwBuffers(boolean purgeReadBuffers, boolean purgeWriteBuffers) throws IOException {
- if (purgeReadBuffers) {
- vendorOut(FLUSH_RX_REQUEST, 0, null);
- }
-
- if (purgeWriteBuffers) {
- vendorOut(FLUSH_TX_REQUEST, 0, null);
- }
-
- return purgeReadBuffers || purgeWriteBuffers;
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java
deleted file mode 100644
index 4a1875629f..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbId.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright 2012 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-package com.hoho.android.usbserial.driver;
-
-/**
- * Registry of USB vendor/product ID constants.
- *
- * Culled from various sources; see
- * usb.ids for one listing.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-public final class UsbId {
-
- public static final int VENDOR_FTDI = 0x0403;
- public static final int FTDI_FT232R = 0x6001;
- public static final int FTDI_FT231X = 0x6015;
-
- public static final int VENDOR_ATMEL = 0x03EB;
- public static final int ATMEL_LUFA_CDC_DEMO_APP = 0x2044;
-
- public static final int VENDOR_ARDUINO = 0x2341;
- public static final int VENDOR_ARDUINO2 = 0x26ac;
- public static final int ARDUINO_UNO = 0x0001;
- public static final int ARDUINO_MEGA_2560 = 0x0010;
- public static final int ARDUINO_SERIAL_ADAPTER = 0x003b;
- public static final int ARDUINO_MEGA_ADK = 0x003f;
- public static final int ARDUINO_MEGA_2560_R3 = 0x0042;
- public static final int ARDUINO_UNO_R3 = 0x0043;
- public static final int ARDUINO_MEGA_ADK_R3 = 0x0044;
- public static final int ARDUINO_SERIAL_ADAPTER_R3 = 0x0044;
- public static final int ARDUINO_LEONARDO = 0x8036;
- public static final int PIXHAWK = 0x0011;
-
- public static final int VENDOR_VAN_OOIJEN_TECH = 0x16c0;
- public static final int VAN_OOIJEN_TECH_TEENSYDUINO_SERIAL = 0x0483;
-
- public static final int VENDOR_LEAFLABS = 0x1eaf;
- public static final int LEAFLABS_MAPLE = 0x0004;
-
- public static final int VENDOR_SILAB = 0x10c4;
- public static final int SILAB_CP2102 = 0xea60;
-
- public static final int VENDOR_PROLIFIC = 0x067b;
- public static final int PROLIFIC_PL2303 = 0x2303;
-
- private UsbId() {
- throw new IllegalAccessError("Non-instantiable class.");
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialDriver.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialDriver.java
deleted file mode 100644
index e0e13c0f5d..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialDriver.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/* Copyright 2011 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-
-package com.hoho.android.usbserial.driver;
-
-import java.io.IOException;
-
-/**
- * Driver interface for a USB serial device.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-public interface UsbSerialDriver {
-
- /** 5 data bits. */
- public static final int DATABITS_5 = 5;
-
- /** 6 data bits. */
- public static final int DATABITS_6 = 6;
-
- /** 7 data bits. */
- public static final int DATABITS_7 = 7;
-
- /** 8 data bits. */
- public static final int DATABITS_8 = 8;
-
- /** No flow control. */
- public static final int FLOWCONTROL_NONE = 0;
-
- /** RTS/CTS input flow control. */
- public static final int FLOWCONTROL_RTSCTS_IN = 1;
-
- /** RTS/CTS output flow control. */
- public static final int FLOWCONTROL_RTSCTS_OUT = 2;
-
- /** XON/XOFF input flow control. */
- public static final int FLOWCONTROL_XONXOFF_IN = 4;
-
- /** XON/XOFF output flow control. */
- public static final int FLOWCONTROL_XONXOFF_OUT = 8;
-
- /** No parity. */
- public static final int PARITY_NONE = 0;
-
- /** Odd parity. */
- public static final int PARITY_ODD = 1;
-
- /** Even parity. */
- public static final int PARITY_EVEN = 2;
-
- /** Mark parity. */
- public static final int PARITY_MARK = 3;
-
- /** Space parity. */
- public static final int PARITY_SPACE = 4;
-
- /** 1 stop bit. */
- public static final int STOPBITS_1 = 1;
-
- /** 1.5 stop bits. */
- public static final int STOPBITS_1_5 = 3;
-
- /** 2 stop bits. */
- public static final int STOPBITS_2 = 2;
-
- /**
- * Opens and initializes the device as a USB serial device. Upon success,
- * caller must ensure that {@link #close()} is eventually called.
- *
- * @throws IOException on error opening or initializing the device.
- */
- public void open() throws IOException;
-
- /**
- * Closes the serial device.
- *
- * @throws IOException on error closing the device.
- */
- public void close() throws IOException;
-
- /**
- * Reads as many bytes as possible into the destination buffer.
- *
- * @param dest the destination byte buffer
- * @param timeoutMillis the timeout for reading
- * @return the actual number of bytes read
- * @throws IOException if an error occurred during reading
- */
- public int read(final byte[] dest, final int timeoutMillis) throws IOException;
-
- /**
- * Writes as many bytes as possible from the source buffer.
- *
- * @param src the source byte buffer
- * @param timeoutMillis the timeout for writing
- * @return the actual number of bytes written
- * @throws IOException if an error occurred during writing
- */
- public int write(final byte[] src, final int timeoutMillis) throws IOException;
-
- /**
- * Sets various serial port parameters.
- *
- * @param baudRate baud rate as an integer, for example {@code 115200}.
- * @param dataBits one of {@link #DATABITS_5}, {@link #DATABITS_6},
- * {@link #DATABITS_7}, or {@link #DATABITS_8}.
- * @param stopBits one of {@link #STOPBITS_1}, {@link #STOPBITS_1_5}, or
- * {@link #STOPBITS_2}.
- * @param parity one of {@link #PARITY_NONE}, {@link #PARITY_ODD},
- * {@link #PARITY_EVEN}, {@link #PARITY_MARK}, or
- * {@link #PARITY_SPACE}.
- * @throws IOException on error setting the port parameters
- */
- public void setParameters(
- int baudRate, int dataBits, int stopBits, int parity) throws IOException;
-
- /**
- * Gets the CD (Carrier Detect) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getCD() throws IOException;
-
- /**
- * Gets the CTS (Clear To Send) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getCTS() throws IOException;
-
- /**
- * Gets the DSR (Data Set Ready) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getDSR() throws IOException;
-
- /**
- * Gets the DTR (Data Terminal Ready) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getDTR() throws IOException;
-
- /**
- * Sets the DTR (Data Terminal Ready) bit on the underlying UART, if
- * supported.
- *
- * @param value the value to set
- * @throws IOException if an error occurred during writing
- */
- public void setDTR(boolean value) throws IOException;
-
- /**
- * Gets the RI (Ring Indicator) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getRI() throws IOException;
-
- /**
- * Gets the RTS (Request To Send) bit from the underlying UART.
- *
- * @return the current state, or {@code false} if not supported.
- * @throws IOException if an error occurred during reading
- */
- public boolean getRTS() throws IOException;
-
- /**
- * Sets the RTS (Request To Send) bit on the underlying UART, if
- * supported.
- *
- * @param value the value to set
- * @throws IOException if an error occurred during writing
- */
- public void setRTS(boolean value) throws IOException;
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java
deleted file mode 100644
index f1667e3010..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialProber.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/* Copyright 2011 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-
-package com.hoho.android.usbserial.driver;
-
-import android.hardware.usb.UsbDevice;
-import android.hardware.usb.UsbDeviceConnection;
-import android.hardware.usb.UsbManager;
-import android.util.Log;
-import android.util.SparseArray;
-import android.util.SparseIntArray;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Helper class which finds compatible {@link UsbDevice}s and creates
- * {@link UsbSerialDriver} instances.
- *
- *
- * You don't need a Prober to use the rest of the library: it is perfectly
- * acceptable to instantiate driver instances manually. The Prober simply
- * provides convenience functions.
- *
- *
- * For most drivers, the corresponding {@link #probe(UsbManager, UsbDevice)}
- * method will either return an empty list (device unknown / unsupported) or a
- * singleton list. However, multi-port drivers may return multiple instances.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-public enum UsbSerialProber {
-
- // TODO(mikey): Too much boilerplate.
-
- /**
- * Prober for {@link FtdiSerialDriver}.
- *
- * @see FtdiSerialDriver
- */
- FTDI_SERIAL {
- @Override
- public List probe(final UsbManager manager, final UsbDevice usbDevice) {
- if (!testIfSupported(usbDevice, FtdiSerialDriver.getSupportedDevices())) {
- return Collections.emptyList();
- }
- final UsbDeviceConnection connection = manager.hasPermission(usbDevice)
- ? manager.openDevice(usbDevice)
- : null;
- if (connection == null) {
- return Collections.emptyList();
- }
- final UsbSerialDriver driver = new FtdiSerialDriver(usbDevice, connection);
- return Collections.singletonList(driver);
- }
-
- @Override
- public SparseArray getSupportedDevices(){
- return FtdiSerialDriver.getSupportedDevices();
- }
- },
-
- CDC_ACM_SERIAL {
- @Override
- public List probe(UsbManager manager, UsbDevice usbDevice) {
- if (!testIfSupported(usbDevice, CdcAcmSerialDriver.getSupportedDevices())) {
- return Collections.emptyList();
- }
- final UsbDeviceConnection connection = manager.hasPermission(usbDevice)
- ? manager.openDevice(usbDevice)
- : null;
- if (connection == null) {
- return Collections.emptyList();
- }
- final UsbSerialDriver driver = new CdcAcmSerialDriver(usbDevice, connection);
- return Collections.singletonList(driver);
- }
-
- @Override
- public SparseArray getSupportedDevices(){
- return CdcAcmSerialDriver.getSupportedDevices();
- }
- },
-
- SILAB_SERIAL {
- @Override
- public List probe(final UsbManager manager, final UsbDevice usbDevice) {
- if (!testIfSupported(usbDevice, Cp2102SerialDriver.getSupportedDevices())) {
- return Collections.emptyList();
- }
- final UsbDeviceConnection connection = manager.hasPermission(usbDevice)
- ? manager.openDevice(usbDevice)
- : null;
- if (connection == null) {
- return Collections.emptyList();
- }
- final UsbSerialDriver driver = new Cp2102SerialDriver(usbDevice, connection);
- return Collections.singletonList(driver);
- }
-
- @Override
- public SparseArray getSupportedDevices(){
- return Cp2102SerialDriver.getSupportedDevices();
- }
- },
-
- PROLIFIC_SERIAL {
- @Override
- public List probe(final UsbManager manager, final UsbDevice usbDevice) {
- if (!testIfSupported(usbDevice, ProlificSerialDriver.getSupportedDevices())) {
- return Collections.emptyList();
- }
- final UsbDeviceConnection connection = manager.hasPermission(usbDevice)
- ? manager.openDevice(usbDevice)
- : null;
- if (connection == null) {
- return Collections.emptyList();
- }
- final UsbSerialDriver driver = new ProlificSerialDriver(usbDevice, connection);
- return Collections.singletonList(driver);
- }
-
- @Override
- public SparseArray getSupportedDevices(){
- return ProlificSerialDriver.getSupportedDevices();
- }
- };
-
- /**
- * Tests the supplied {@link UsbDevice} for compatibility with this enum
- * member, returning one or more driver instances if compatible.
- *
- * @param manager the {@link UsbManager} to use
- * @param usbDevice the raw {@link UsbDevice} to use
- * @return zero or more {@link UsbSerialDriver}, depending on compatibility
- * (never {@code null}).
- */
- protected abstract List probe(final UsbManager manager, final UsbDevice usbDevice);
-
- protected abstract SparseArray getSupportedDevices();
-
- /**
- * Creates and returns a new {@link UsbSerialDriver} instance for the first
- * compatible {@link UsbDevice} found on the bus. If none are found,
- * returns {@code null}.
- *
- *
- * The order of devices is undefined, therefore if there are multiple
- * devices on the bus, the chosen device may not be predictable (clients
- * should use {@link #findAllDevices(UsbManager)} instead).
- *
- * @param usbManager the {@link UsbManager} to use.
- * @return the first available {@link UsbSerialDriver}, or {@code null} if
- * none are available.
- */
- public static UsbSerialDriver findFirstDevice(final UsbManager usbManager) {
- for (final UsbDevice usbDevice : usbManager.getDeviceList().values()) {
- for (final UsbSerialProber prober : values()) {
- final List probedDevices = prober.probe(usbManager, usbDevice);
- if (!probedDevices.isEmpty()) {
- return probedDevices.get(0);
- }
- }
- }
- return null;
- }
-
- public static UsbSerialDriver openUsbDevice(final UsbManager usbManager,
- final UsbDevice device){
- for (final UsbSerialProber prober : values()) {
- final List probedDevices = prober.probe(usbManager, device);
- if (!probedDevices.isEmpty()) {
- return probedDevices.get(0);
- }
- }
-
- return null;
- }
-
- public static List getAvailableSupportedDevices(final UsbManager usbManager){
- List supportedDevices = new ArrayList();
- for(UsbDevice usbDevice: usbManager.getDeviceList().values()){
- for(UsbSerialProber prober: values()) {
- if (testIfSupported(usbDevice, prober.getSupportedDevices())){
- supportedDevices.add(usbDevice);
- break;
- }
- }
- }
-
- return supportedDevices;
- }
-
- /**
- * Creates a new {@link UsbSerialDriver} instance for all compatible
- * {@link UsbDevice}s found on the bus. If no compatible devices are found,
- * the list will be empty.
- *
- * @param usbManager
- * @return
- */
- public static List findAllDevices(final UsbManager usbManager) {
- final List result = new ArrayList();
-
- // For each UsbDevice, call probe() for each prober.
- for (final UsbDevice usbDevice : usbManager.getDeviceList().values()) {
- result.addAll(probeSingleDevice(usbManager, usbDevice));
- }
- return result;
- }
-
- /**
- * Special method for testing a specific device for driver support,
- * returning any compatible driver(s).
- *
- *
- * Clients should ordinarily use {@link #findAllDevices(UsbManager)}, which
- * operates against the entire bus of devices. This method is useful when
- * testing against only a single target is desired.
- *
- * @param usbManager the {@link UsbManager} to use.
- * @param usbDevice the device to test against.
- * @return a list containing zero or more {@link UsbSerialDriver} instances.
- */
- public static List probeSingleDevice(final UsbManager usbManager,
- UsbDevice usbDevice) {
- final List result = new ArrayList();
- for (final UsbSerialProber prober : values()) {
- final List probedDevices = prober.probe(usbManager, usbDevice);
- result.addAll(probedDevices);
- }
- return result;
- }
-
- /**
- * Deprecated; Use {@link #findFirstDevice(UsbManager)}.
- *
- * @param usbManager
- * @return
- */
- @Deprecated
- public static UsbSerialDriver acquire(final UsbManager usbManager) {
- return findFirstDevice(usbManager);
- }
-
- /**
- * Deprecated; use {@link #probeSingleDevice(UsbManager, UsbDevice)}.
- *
- * @param usbManager
- * @param usbDevice
- * @return
- */
- @Deprecated
- public static UsbSerialDriver acquire(final UsbManager usbManager, final UsbDevice usbDevice) {
- final List probedDevices = probeSingleDevice(usbManager, usbDevice);
- if (!probedDevices.isEmpty()) {
- return probedDevices.get(0);
- }
- return null;
- }
-
- /**
- * Returns {@code true} if the given device is found in the driver's
- * vendor/product map.
- *
- * @param usbDevice the device to test
- * @param supportedDevices map of vendor IDs to product ID(s)
- * @return {@code true} if supported
- */
- private static boolean testIfSupported(final UsbDevice usbDevice,
- final SparseArray supportedDevices) {
- final int[] supportedProducts = supportedDevices.get(usbDevice.getVendorId());
- if (supportedProducts == null) {
- return false;
- }
-
- final int productId = usbDevice.getProductId();
- for (int supportedProductId : supportedProducts) {
- if (productId == supportedProductId) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialRuntimeException.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialRuntimeException.java
deleted file mode 100644
index b48607c59d..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/driver/UsbSerialRuntimeException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- */
-
-package com.hoho.android.usbserial.driver;
-
-/**
- * Generic unchecked exception for the usbserial package.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-@SuppressWarnings("serial")
-public class UsbSerialRuntimeException extends RuntimeException {
-
- public UsbSerialRuntimeException() {
- super();
- }
-
- public UsbSerialRuntimeException(String detailMessage, Throwable throwable) {
- super(detailMessage, throwable);
- }
-
- public UsbSerialRuntimeException(String detailMessage) {
- super(detailMessage);
- }
-
- public UsbSerialRuntimeException(Throwable throwable) {
- super(throwable);
- }
-
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/HexDump.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/HexDump.java
deleted file mode 100644
index 54f6e4272e..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/HexDump.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hoho.android.usbserial.util;
-
-/**
- * Clone of Android's HexDump class, for use in debugging. Cosmetic changes
- * only.
- */
-public class HexDump {
- private final static char[] HEX_DIGITS = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
- };
-
- public static String dumpHexString(byte[] array) {
- return dumpHexString(array, 0, array.length);
- }
-
- public static String dumpHexString(byte[] array, int offset, int length) {
- StringBuilder result = new StringBuilder();
-
- byte[] line = new byte[16];
- int lineIndex = 0;
-
- result.append("\n0x");
- result.append(toHexString(offset));
-
- for (int i = offset; i < offset + length; i++) {
- if (lineIndex == 16) {
- result.append(" ");
-
- for (int j = 0; j < 16; j++) {
- if (line[j] > ' ' && line[j] < '~') {
- result.append(new String(line, j, 1));
- } else {
- result.append(".");
- }
- }
-
- result.append("\n0x");
- result.append(toHexString(i));
- lineIndex = 0;
- }
-
- byte b = array[i];
- result.append(" ");
- result.append(HEX_DIGITS[(b >>> 4) & 0x0F]);
- result.append(HEX_DIGITS[b & 0x0F]);
-
- line[lineIndex++] = b;
- }
-
- if (lineIndex != 16) {
- int count = (16 - lineIndex) * 3;
- count++;
- for (int i = 0; i < count; i++) {
- result.append(" ");
- }
-
- for (int i = 0; i < lineIndex; i++) {
- if (line[i] > ' ' && line[i] < '~') {
- result.append(new String(line, i, 1));
- } else {
- result.append(".");
- }
- }
- }
-
- return result.toString();
- }
-
- public static String toHexString(byte b) {
- return toHexString(toByteArray(b));
- }
-
- public static String toHexString(byte[] array) {
- return toHexString(array, 0, array.length);
- }
-
- public static String toHexString(byte[] array, int offset, int length) {
- char[] buf = new char[length * 2];
-
- int bufIndex = 0;
- for (int i = offset; i < offset + length; i++) {
- byte b = array[i];
- buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
- buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
- }
-
- return new String(buf);
- }
-
- public static String toHexString(int i) {
- return toHexString(toByteArray(i));
- }
-
- public static String toHexString(short i) {
- return toHexString(toByteArray(i));
- }
-
- public static byte[] toByteArray(byte b) {
- byte[] array = new byte[1];
- array[0] = b;
- return array;
- }
-
- public static byte[] toByteArray(int i) {
- byte[] array = new byte[4];
-
- array[3] = (byte) (i & 0xFF);
- array[2] = (byte) ((i >> 8) & 0xFF);
- array[1] = (byte) ((i >> 16) & 0xFF);
- array[0] = (byte) ((i >> 24) & 0xFF);
-
- return array;
- }
-
- public static byte[] toByteArray(short i) {
- byte[] array = new byte[2];
-
- array[1] = (byte) (i & 0xFF);
- array[0] = (byte) ((i >> 8) & 0xFF);
-
- return array;
- }
-
- private static int toByte(char c) {
- if (c >= '0' && c <= '9')
- return (c - '0');
- if (c >= 'A' && c <= 'F')
- return (c - 'A' + 10);
- if (c >= 'a' && c <= 'f')
- return (c - 'a' + 10);
-
- throw new RuntimeException("Invalid hex char '" + c + "'");
- }
-
- public static byte[] hexStringToByteArray(String hexString) {
- int length = hexString.length();
- byte[] buffer = new byte[length / 2];
-
- for (int i = 0; i < length; i += 2) {
- buffer[i / 2] = (byte) ((toByte(hexString.charAt(i)) << 4) | toByte(hexString
- .charAt(i + 1)));
- }
-
- return buffer;
- }
-}
diff --git a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/SerialInputOutputManager.java b/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/SerialInputOutputManager.java
deleted file mode 100644
index d0be45e96a..0000000000
--- a/dependencyLibs/usb-serial-for-android/UsbSerialLibrary/src/com/hoho/android/usbserial/util/SerialInputOutputManager.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Copyright 2011 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
- *
- * Project home page: http://code.google.com/p/usb-serial-for-android/
- */
-
-package com.hoho.android.usbserial.util;
-
-import android.hardware.usb.UsbRequest;
-import android.util.Log;
-
-import com.hoho.android.usbserial.driver.UsbSerialDriver;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * Utility class which services a {@link UsbSerialDriver} in its {@link #run()}
- * method.
- *
- * @author mike wakerly (opensource@hoho.com)
- */
-public class SerialInputOutputManager implements Runnable {
-
- private static final String TAG = SerialInputOutputManager.class.getSimpleName();
- private static final boolean DEBUG = true;
-
- private static final int READ_WAIT_MILLIS = 200;
- private static final int BUFSIZ = 4096;
-
- private final UsbSerialDriver mDriver;
-
- private final ByteBuffer mReadBuffer = ByteBuffer.allocate(BUFSIZ);
-
- // Synchronized by 'mWriteBuffer'
- private final ByteBuffer mWriteBuffer = ByteBuffer.allocate(BUFSIZ);
-
- private enum State {
- STOPPED,
- RUNNING,
- STOPPING
- }
-
- // Synchronized by 'this'
- private State mState = State.STOPPED;
-
- // Synchronized by 'this'
- private Listener mListener;
-
- public interface Listener {
- /**
- * Called when new incoming data is available.
- */
- public void onNewData(byte[] data);
-
- /**
- * Called when {@link SerialInputOutputManager#run()} aborts due to an
- * error.
- */
- public void onRunError(Exception e);
- }
-
- /**
- * Creates a new instance with no listener.
- */
- public SerialInputOutputManager(UsbSerialDriver driver) {
- this(driver, null);
- }
-
- /**
- * Creates a new instance with the provided listener.
- */
- public SerialInputOutputManager(UsbSerialDriver driver, Listener listener) {
- mDriver = driver;
- mListener = listener;
- }
-
- public synchronized void setListener(Listener listener) {
- mListener = listener;
- }
-
- public synchronized Listener getListener() {
- return mListener;
- }
-
- public void writeAsync(byte[] data) {
- synchronized (mWriteBuffer) {
- mWriteBuffer.put(data);
- }
- }
-
- public synchronized void stop() {
- if (getState() == State.RUNNING) {
- Log.i(TAG, "Stop requested");
- mState = State.STOPPING;
- }
- }
-
- private synchronized State getState() {
- return mState;
- }
-
- /**
- * Continuously services the read and write buffers until {@link #stop()} is
- * called, or until a driver exception is raised.
- *
- * NOTE(mikey): Uses inefficient read/write-with-timeout.
- * TODO(mikey): Read asynchronously with {@link UsbRequest#queue(ByteBuffer, int)}
- */
- @Override
- public void run() {
- synchronized (this) {
- if (getState() != State.STOPPED) {
- throw new IllegalStateException("Already running.");
- }
- mState = State.RUNNING;
- }
-
- Log.i(TAG, "Running ..");
- try {
- while (true) {
- if (getState() != State.RUNNING) {
- Log.i(TAG, "Stopping mState=" + getState());
- break;
- }
- step();
- }
- } catch (Exception e) {
- Log.w(TAG, "Run ending due to exception: " + e.getMessage(), e);
- final Listener listener = getListener();
- if (listener != null) {
- listener.onRunError(e);
- }
- } finally {
- synchronized (this) {
- mState = State.STOPPED;
- Log.i(TAG, "Stopped.");
- }
- }
- }
-
- private void step() throws IOException {
- // Handle incoming data.
- int len = mDriver.read(mReadBuffer.array(), READ_WAIT_MILLIS);
- if (len > 0) {
- if (DEBUG) Log.d(TAG, "Read data len=" + len);
- final Listener listener = getListener();
- if (listener != null) {
- final byte[] data = new byte[len];
- mReadBuffer.get(data, 0, len);
- listener.onNewData(data);
- }
- mReadBuffer.clear();
- }
-
- // Handle outgoing data.
- byte[] outBuff = null;
- synchronized (mWriteBuffer) {
- if (mWriteBuffer.position() > 0) {
- len = mWriteBuffer.position();
- outBuff = new byte[len];
- mWriteBuffer.rewind();
- mWriteBuffer.get(outBuff, 0, len);
- mWriteBuffer.clear();
- }
- }
- if (outBuff != null) {
- if (DEBUG) {
- Log.d(TAG, "Writing data len=" + len);
- }
- mDriver.write(outBuff, READ_WAIT_MILLIS);
- }
- }
-
-}
diff --git a/doc/first_app.rst b/doc/first_app.rst
index 654097ba4c..30f061305e 100644
--- a/doc/first_app.rst
+++ b/doc/first_app.rst
@@ -28,13 +28,13 @@ Project Setup
Adding the Client Library
=========================
-To add the 3DR Services library to your project:
+To add the DroneKit-Android Client library to your project:
#. Open **build.gradle (Module:app)** and, under the dependencies section, add:
.. code-block:: bash
- compile 'com.o3dr.android:dronekit-android:2.3.+'
+ compile 'com.o3dr.android:dronekit-android:3.0.+'
#. Click **Sync** in the top-right corner to re-sync the gradle:
@@ -43,10 +43,10 @@ To add the 3DR Services library to your project:
-Connecting to 3DR Services
+Connecting to DroneKit-Android
==========================
-Implement a ``TowerListener`` on your ``MainActivity`` to listen for events sent from 3DR Services to your app.
+Implement a ``TowerListener`` on your ``MainActivity`` to listen for events sent from the library to your app.
.. code-block:: java
:linenos:
@@ -54,7 +54,7 @@ Implement a ``TowerListener`` on your ``MainActivity`` to listen for events sent
public class MainActivity extends ActionBarActivity implements TowerListener {
- // 3DR Services Listener
+ // DroneKit-Android Listener
@Override
public void onTowerConnected() {
@@ -75,8 +75,8 @@ Implement a ``TowerListener`` on your ``MainActivity`` to listen for events sent
Now you'll need to:
-1. Add a ``ControlTower`` instance to manage the communication to 3DR Services.
-2. Connect to 3DR Services on start of the ``MainActivity`` and disconnect on its stop.
+1. Add a ``ControlTower`` instance to manage the communication to the Client library.
+2. Connect to the Client library on start of the ``MainActivity`` and disconnect on its stop.
.. code-block:: java
:linenos:
diff --git a/doc/getting_started.rst b/doc/getting_started.rst
index 381cf39f45..32ce711c60 100644
--- a/doc/getting_started.rst
+++ b/doc/getting_started.rst
@@ -36,7 +36,7 @@ For an existing app:
#. Open the **build.gradle** file inside your application module directory. Android Studio projects contain a top level **build.gradle** file and a **build.gradle** for each module. Make sure to edit the file for your application module.
-#. Add a new build rule under dependencies for the latest version of the 3DR Services Client library. For example:
+#. Add a new build rule under dependencies for the latest version of the DroneKit-Android Client library. For example:
.. code-block:: bash
@@ -48,13 +48,6 @@ For an existing app:
}
dependencies {
- compile 'com.o3dr.android:dronekit-android:2.3.+'
+ compile 'com.o3dr.android:dronekit-android:3.0.+'
...
}
-
-Installing 3DR Services on your Mobile Device
-=============================================
-
-For any DroneKit apps to work on Android, the *3DR Services* app must be installed. This app provides a communication layer to the drone and showcases apps built on DroneKit.
-
-You can `install 3DR Services from here `_.
diff --git a/doc/index.rst b/doc/index.rst
index d7c2a7d138..8a6d12964a 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -11,9 +11,6 @@ DroneKit-Android provides interfaces for Android applications to control 3DR-pow
DroneKit is compatible with all vehicles using the `MAVLink protocol `_. This includes most vehicles made by 3DR and other members of the `DroneCode foundation `_.
-A catalog of android apps built with DroneKit can be found in `3DR Services `_ (Google Play Store).
-
-
Contents:
=========
diff --git a/doc/resources.rst b/doc/resources.rst
index b3fb99f195..dae1a5d206 100644
--- a/doc/resources.rst
+++ b/doc/resources.rst
@@ -38,7 +38,7 @@ Tower (Droidplanner 3)
The most used Android ground control station for drones.
-`Source `_ | `Play Store `_
+`Source `_ | `Play Store `_
Tower Pebble
----------
diff --git a/release_android_library.gradle b/release_android_library.gradle
deleted file mode 100644
index cf6f1f672c..0000000000
--- a/release_android_library.gradle
+++ /dev/null
@@ -1,114 +0,0 @@
-apply plugin: 'maven-publish'
-apply plugin: 'com.jfrog.bintray'
-
-def publishFlag = false
-def projectGroupId = 'com.o3dr.android'
-def projectArtifactId = project.PUBLISH_ARTIFACT_ID
-def projectVersion = project.PUBLISH_VERSION
-def projectDescription = project.PROJECT_DESCRIPTION
-def projectLabels = project.PROJECT_LABELS
-def projectLicenses = project.PROJECT_LICENSES
-
-task androidJavadocs(type: Javadoc) {
- //Add the project java source directory.
- def files = [android.sourceSets.main.java.srcDirs]
-
- //Add the java source directories for the project's dependencies
- configurations.compile.dependencies.each {
- if (it instanceof ProjectDependency) {
- def dependency = it as ProjectDependency
- def depProj = dependency.getDependencyProject()
- def projName = depProj.getName()
- if(projName != "Mavlink") {
- files += depProj.android.sourceSets.main.java.srcDirs
- }
- }
- }
-
- source = files
- title = projectDescription
- exclude '**/*.aidl'
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
- options.links("http://docs.oracle.com/javase/7/docs/api/")
- options.links("https://developer.android.com/reference/packages.html")
-}
-
-task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs){
- classifier = 'javadoc'
- from androidJavadocs.destinationDir
-}
-
-task androidSourcesJar(type: Jar){
- classifier = 'sources'
- from android.sourceSets.main.java.srcDirs
-}
-
-artifacts {
- archives androidSourcesJar
- archives androidJavadocsJar
-}
-
-publishing {
- publications {
- mavenLibraryRelease(MavenPublication){
- groupId projectGroupId
- artifactId projectArtifactId
- version projectVersion
-
- artifact "build/outputs/aar/${PUBLISH_ARTIFACT_ID}.${PUBLISH_VERSION}.aar"
-
- artifact androidSourcesJar {
- classifier 'sources'
- }
-
- artifact androidJavadocsJar {
- classifier 'javadoc'
- }
- }
- }
-}
-
-bintray {
- user = getMavenUsername()
- key = getMavenApiKey()
-
- publications = ['mavenLibraryRelease'] //When uploading Maven-based publication files
- dryRun = false //Whether to run this as dry-run, without deploying
- publish = publishFlag //If version should be auto published after an upload
-
- pkg {
- userOrg = getMavenOrg()
- repo = getMavenRepo()
- name = projectArtifactId
- desc = projectDescription
- websiteUrl = 'http://android.dronekit.io/'
- issueTrackerUrl = 'https://github.com/DroidPlanner/DroneKit-Android/issues'
- vcsUrl = 'https://github.com/DroidPlanner/DroneKit-Android.git'
- licenses = projectLicenses
- labels = projectLabels
- publicDownloadNumbers = true
-
- //Optional version descriptor
- version {
- name = projectVersion //Bintray logical version name
- }
- }
-}
-
-bintrayUpload.dependsOn(publishToMavenLocal)
-
-def getMavenOrg(){
- return hasProperty('COM_O3DR_MAVEN_ORG') ? COM_O3DR_MAVEN_ORG : ''
-}
-
-def getMavenUsername(){
- return hasProperty('COM_O3DR_MAVEN_USERNAME') ? COM_O3DR_MAVEN_USERNAME : ''
-}
-
-def getMavenApiKey(){
- return hasProperty('COM_O3DR_MAVEN_APIKEY') ? COM_O3DR_MAVEN_APIKEY : ''
-}
-
-def getMavenRepo(){
- return hasProperty('COM_O3DR_MAVEN_REPO') ? COM_O3DR_MAVEN_REPO : ''
-}
\ No newline at end of file
diff --git a/samples/StarterApp/build.gradle b/samples/StarterApp/build.gradle
index b492373575..9f324a1f60 100644
--- a/samples/StarterApp/build.gradle
+++ b/samples/StarterApp/build.gradle
@@ -18,16 +18,16 @@ android {
}
}
- //FIXME: Remove when lint errors are taken care of.
lintOptions {
abortOnError false
}
+
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile "com.android.support:appcompat-v7:${support_lib_version}"
- compile "com.android.support:cardview-v7:${support_lib_version}"
+ compile "com.android.support:appcompat-v7:23.4.0"
+ compile "com.android.support:cardview-v7:23.4.0"
compile project(':ClientLib')
}
\ No newline at end of file
diff --git a/samples/StarterApp/src/androidTest/java/com/o3dr/hellodrone/ApplicationTest.java b/samples/StarterApp/src/androidTest/java/org/droidplanner/hellodrone/ApplicationTest.java
similarity index 87%
rename from samples/StarterApp/src/androidTest/java/com/o3dr/hellodrone/ApplicationTest.java
rename to samples/StarterApp/src/androidTest/java/org/droidplanner/hellodrone/ApplicationTest.java
index c7f0b9e3c8..361f687a0e 100644
--- a/samples/StarterApp/src/androidTest/java/com/o3dr/hellodrone/ApplicationTest.java
+++ b/samples/StarterApp/src/androidTest/java/org/droidplanner/hellodrone/ApplicationTest.java
@@ -1,4 +1,4 @@
-package com.o3dr.sample.hellodrone;
+package org.droidplanner.sample.hellodrone;
import android.app.Application;
import android.test.ApplicationTestCase;
diff --git a/samples/StarterApp/src/main/AndroidManifest.xml b/samples/StarterApp/src/main/AndroidManifest.xml
index f303613986..457cc154ab 100644
--- a/samples/StarterApp/src/main/AndroidManifest.xml
+++ b/samples/StarterApp/src/main/AndroidManifest.xml
@@ -1,14 +1,15 @@
+ package="org.droidplanner.sample.hellodrone" >
diff --git a/samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/MainActivity.java b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/MainActivity.java
similarity index 95%
rename from samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/MainActivity.java
rename to samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/MainActivity.java
index 738506e70a..98251e8c35 100644
--- a/samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/MainActivity.java
+++ b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/MainActivity.java
@@ -1,10 +1,11 @@
-package com.o3dr.sample.hellodrone;
+package org.droidplanner.sample.hellodrone;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
+import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Surface;
@@ -21,9 +22,10 @@
import com.o3dr.android.client.Drone;
import com.o3dr.android.client.apis.ControlApi;
import com.o3dr.android.client.apis.ExperimentalApi;
-import com.o3dr.android.client.apis.solo.SoloCameraApi;
import com.o3dr.android.client.apis.VehicleApi;
+import com.o3dr.android.client.apis.solo.SoloCameraApi;
import com.o3dr.android.client.interfaces.DroneListener;
+import com.o3dr.android.client.interfaces.LinkListener;
import com.o3dr.android.client.interfaces.TowerListener;
import com.o3dr.android.client.utils.video.DecoderListener;
import com.o3dr.android.client.utils.video.MediaCodecManager;
@@ -34,7 +36,6 @@
import com.o3dr.services.android.lib.drone.companion.solo.SoloAttributes;
import com.o3dr.services.android.lib.drone.companion.solo.SoloState;
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
-import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
import com.o3dr.services.android.lib.drone.property.Altitude;
import com.o3dr.services.android.lib.drone.property.Gps;
@@ -43,15 +44,16 @@
import com.o3dr.services.android.lib.drone.property.State;
import com.o3dr.services.android.lib.drone.property.Type;
import com.o3dr.services.android.lib.drone.property.VehicleMode;
+import com.o3dr.services.android.lib.gcs.link.LinkConnectionStatus;
import com.o3dr.services.android.lib.model.AbstractCommandListener;
import com.o3dr.services.android.lib.model.SimpleCommandListener;
import java.io.IOException;
import java.util.List;
-import static com.o3dr.android.client.apis.ExperimentalApi.*;
+import static com.o3dr.android.client.apis.ExperimentalApi.getApi;
-public class MainActivity extends AppCompatActivity implements DroneListener, TowerListener {
+public class MainActivity extends AppCompatActivity implements DroneListener, TowerListener, LinkListener {
private static final String TAG = MainActivity.class.getSimpleName();
private Drone drone;
@@ -211,19 +213,19 @@ public void onStop() {
this.controlTower.disconnect();
}
- // 3DR Services Listener
+ // DroneKit-Android Listener
// ==========================================================
@Override
public void onTowerConnected() {
- alertUser("3DR Services Connected");
+ alertUser("DroneKit-Android Connected");
this.controlTower.registerDrone(this.drone, this.handler);
this.drone.registerDroneListener(this);
}
@Override
public void onTowerDisconnected() {
- alertUser("3DR Service Interrupted");
+ alertUser("DroneKit-Android Interrupted");
}
// Drone Listener
@@ -290,11 +292,6 @@ private void checkSoloState() {
}
}
- @Override
- public void onDroneConnectionFailed(ConnectionResult result) {
- alertUser("Connection Failed:" + result.getErrorCode());
- }
-
@Override
public void onDroneServiceInterrupted(String errorMsg) {
@@ -310,14 +307,10 @@ public void onBtnConnectTap(View view) {
Spinner connectionSelector = (Spinner) findViewById(R.id.selectConnectionType);
int selectedConnectionType = connectionSelector.getSelectedItemPosition();
- Bundle extraParams = new Bundle();
- if (selectedConnectionType == ConnectionType.TYPE_USB) {
- extraParams.putInt(ConnectionType.EXTRA_USB_BAUD_RATE, DEFAULT_USB_BAUD_RATE); // Set default baud rate to 57600
- } else {
- extraParams.putInt(ConnectionType.EXTRA_UDP_SERVER_PORT, DEFAULT_UDP_PORT); // Set default baud rate to 14550
- }
+ ConnectionParameter connectionParams = selectedConnectionType == ConnectionType.TYPE_USB
+ ? ConnectionParameter.newUsbConnection(null)
+ : ConnectionParameter.newUdpConnection(null);
- ConnectionParameter connectionParams = new ConnectionParameter(selectedConnectionType, extraParams, null);
this.drone.connect(connectionParams);
}
@@ -724,4 +717,18 @@ public void onTimeout() {
private void stopVideoStreamForObserver() {
getApi(drone).stopVideoStream(videoTag);
}
+
+ @Override
+ public void onLinkStateUpdated(@NonNull LinkConnectionStatus connectionStatus) {
+ switch(connectionStatus.getStatusCode()){
+ case LinkConnectionStatus.FAILED:
+ Bundle extras = connectionStatus.getExtras();
+ String msg = null;
+ if (extras != null) {
+ msg = extras.getString(LinkConnectionStatus.EXTRA_ERROR_MSG);
+ }
+ alertUser("Connection Failed:" + msg);
+ break;
+ }
+ }
}
diff --git a/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/StarterApplication.java b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/StarterApplication.java
new file mode 100644
index 0000000000..2e0bf1f3a5
--- /dev/null
+++ b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/StarterApplication.java
@@ -0,0 +1,42 @@
+package org.droidplanner.sample.hellodrone;
+
+import android.app.Application;
+
+import com.o3dr.android.client.utils.LogToFileTree;
+
+import timber.log.Timber;
+
+/**
+ * Created by fredia on 5/20/16.
+ */
+public class StarterApplication extends Application {
+
+ /**
+ * Used to channel logging
+ */
+ private LogToFileTree logToFileTree;
+
+ @Override
+ public void onCreate(){
+ super.onCreate();
+
+ if (com.o3dr.android.client.BuildConfig.DEBUG) {
+ logToFileTree = new LogToFileTree();
+ Timber.plant(logToFileTree);
+ }
+
+ createFileStartLogging();
+ }
+
+ private void createFileStartLogging() {
+ if (logToFileTree != null) {
+ logToFileTree.createFileStartLogging(getApplicationContext());
+ }
+ }
+
+ private void closeLogFile() {
+ if(logToFileTree != null) {
+ logToFileTree.stopLoggingThread();
+ }
+ }
+}
diff --git a/samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/video/VideoStreamActivity.java b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/video/VideoStreamActivity.java
similarity index 79%
rename from samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/video/VideoStreamActivity.java
rename to samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/video/VideoStreamActivity.java
index 839557aed1..a848ad158c 100644
--- a/samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/video/VideoStreamActivity.java
+++ b/samples/StarterApp/src/main/java/org/droidplanner/sample/hellodrone/video/VideoStreamActivity.java
@@ -1,9 +1,9 @@
-package com.o3dr.sample.hellodrone.video;
+package org.droidplanner.sample.hellodrone.video;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
-import com.o3dr.sample.hellodrone.R;
+import org.droidplanner.sample.hellodrone.R;
/**
* Created by Fredia Huya-Kouadio on 10/10/15.
diff --git a/settings.gradle b/settings.gradle
index f8a9508776..edc0505848 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,11 +1,11 @@
-//Android projects
-include ':ServiceApp', ':StarterApp'
-include ':ClientLib'
-
//Library projects
include ':Mavlink'
-include ':UsbSerialLibrary'
-project(':UsbSerialLibrary').projectDir = new File('dependencyLibs/usb-serial-for-android/UsbSerialLibrary')
+//Android library projects
+include ':ClientLib'
+
+//Android projects
+include ':StarterApp'
+
project(':Mavlink').projectDir = new File('dependencyLibs/Mavlink')
project(':StarterApp').projectDir = new File('samples/StarterApp')
\ No newline at end of file