mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Small upgrades to teh android install
This commit is contained in:
parent
739dc0f984
commit
4a38eac0db
@ -5,5 +5,6 @@
|
||||
<classpathentry kind="src" path="tests"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
|
@ -14,7 +14,7 @@
|
||||
-keep public class * extends android.preference.Preference
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
-keepclasseswithmembers class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<Button
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/object_browser_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/launch_object_browser"
|
||||
android:drawableLeft="@drawable/browser_icon" android:layout_centerHorizontal="true"/>
|
||||
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pfd_name" android:id="@+id/launch_pfd" android:drawableLeft="@drawable/browser_icon" android:layout_below="@+id/launch_object_browser" android:layout_alignLeft="@+id/launch_object_browser" android:layout_alignRight="@+id/launch_object_browser"></Button>
|
||||
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/location_name" android:id="@+id/launch_location" android:drawableLeft="@drawable/browser_icon" android:layout_below="@+id/launch_pfd" android:layout_alignLeft="@+id/launch_object_browser" android:layout_alignRight="@+id/launch_object_browser"></Button>
|
||||
</RelativeLayout>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/launch_object_browser"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:drawableLeft="@drawable/browser_icon"
|
||||
android:text="@string/object_browser_name" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/launch_pfd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/launch_object_browser"
|
||||
android:layout_alignRight="@+id/launch_object_browser"
|
||||
android:layout_below="@+id/launch_object_browser"
|
||||
android:drawableLeft="@drawable/browser_icon"
|
||||
android:text="@string/pfd_name" >
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/launch_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/launch_object_browser"
|
||||
android:layout_alignRight="@+id/launch_object_browser"
|
||||
android:layout_below="@+id/launch_pfd"
|
||||
android:drawableLeft="@drawable/browser_icon"
|
||||
android:text="@string/location_name" >
|
||||
</Button>
|
||||
|
||||
</RelativeLayout>
|
@ -71,21 +71,25 @@ public class OPTelemetryService extends Service {
|
||||
stopSelf(msg.arg2);
|
||||
break;
|
||||
case MSG_CONNECT:
|
||||
Toast.makeText(getApplicationContext(), "Attempting connection", Toast.LENGTH_SHORT).show();
|
||||
terminate = false;
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
||||
//int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
||||
int connection_type = 1;
|
||||
int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
||||
switch(connection_type) {
|
||||
case 0: // No connection
|
||||
return;
|
||||
case 1:
|
||||
Toast.makeText(getApplicationContext(), "Attempting fake connection", Toast.LENGTH_SHORT).show();
|
||||
activeTelem = new FakeTelemetryThread();
|
||||
break;
|
||||
case 2:
|
||||
Toast.makeText(getApplicationContext(), "Attempting BT connection", Toast.LENGTH_SHORT).show();
|
||||
activeTelem = new BTTelemetryThread();
|
||||
break;
|
||||
case 3:
|
||||
Toast.makeText(getApplicationContext(), "Attempting TCP connection", Toast.LENGTH_SHORT).show();
|
||||
activeTelem = new TcpTelemetryThread();
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unsupported");
|
||||
}
|
||||
activeTelem.start();
|
||||
@ -329,6 +333,75 @@ public class OPTelemetryService extends Service {
|
||||
|
||||
};
|
||||
|
||||
private class TcpTelemetryThread extends Thread implements TelemTask {
|
||||
|
||||
private UAVObjectManager objMngr;
|
||||
private UAVTalk uavTalk;
|
||||
private Telemetry tel;
|
||||
private TelemetryMonitor mon;
|
||||
|
||||
public UAVObjectManager getObjectManager() { return objMngr; };
|
||||
|
||||
TcpTelemetryThread() {
|
||||
objMngr = new UAVObjectManager();
|
||||
UAVObjectsInitialize.register(objMngr);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (DEBUG) Log.d(TAG, "Telemetry Thread started");
|
||||
|
||||
Looper.prepare();
|
||||
|
||||
TcpUAVTalk tcp = new TcpUAVTalk(OPTelemetryService.this);
|
||||
for( int i = 0; i < 10; i++ ) {
|
||||
if (DEBUG) Log.d(TAG, "Attempting network Connection");
|
||||
|
||||
tcp.connect(objMngr);
|
||||
|
||||
if (DEBUG) Log.d(TAG, "Done attempting connection");
|
||||
if( tcp.getConnected() )
|
||||
break;
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "Thread interrupted while trying to connect");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( ! tcp.getConnected() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (DEBUG) Log.d(TAG, "Connected via network");
|
||||
|
||||
uavTalk = tcp.getUavtalk();
|
||||
tel = new Telemetry(uavTalk, objMngr);
|
||||
mon = new TelemetryMonitor(objMngr,tel);
|
||||
mon.addObserver(new Observer() {
|
||||
public void update(Observable arg0, Object arg1) {
|
||||
System.out.println("Mon updated. Connected: " + mon.getConnected() + " objects updated: " + mon.getObjectsUpdated());
|
||||
if(mon.getConnected() /*&& mon.getObjectsUpdated()*/) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(INTENT_ACTION_CONNECTED);
|
||||
sendBroadcast(intent,null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (DEBUG) Log.d(TAG, "Entering UAVTalk processing loop");
|
||||
while( !terminate ) {
|
||||
if( !uavTalk.processInputStream() )
|
||||
break;
|
||||
}
|
||||
if (DEBUG) Log.d(TAG, "UAVTalk stream disconnected");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void postNotification(int id, String message) {
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNManager = (NotificationManager) getSystemService(ns);
|
||||
|
Loading…
x
Reference in New Issue
Block a user