mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Small upgrades to teh android install
This commit is contained in:
parent
e1ba3d2e63
commit
92764ebc67
@ -5,5 +5,6 @@
|
|||||||
<classpathentry kind="src" path="tests"/>
|
<classpathentry kind="src" path="tests"/>
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<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="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"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
-keep public class * extends android.preference.Preference
|
-keep public class * extends android.preference.Preference
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
-keep public class com.android.vending.licensing.ILicensingService
|
||||||
|
|
||||||
-keepclasseswithmembernames class * {
|
-keepclasseswithmembers class * {
|
||||||
native <methods>;
|
native <methods>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,37 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent" >
|
||||||
android:layout_height="match_parent">
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_alignParentTop="true"
|
android:id="@+id/launch_object_browser"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:text="@string/object_browser_name"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_alignParentTop="true"
|
||||||
android:id="@+id/launch_object_browser"
|
android:layout_centerHorizontal="true"
|
||||||
android:drawableLeft="@drawable/browser_icon" android:layout_centerHorizontal="true"/>
|
android:drawableLeft="@drawable/browser_icon"
|
||||||
<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>
|
android:text="@string/object_browser_name" />
|
||||||
<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>
|
<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);
|
stopSelf(msg.arg2);
|
||||||
break;
|
break;
|
||||||
case MSG_CONNECT:
|
case MSG_CONNECT:
|
||||||
Toast.makeText(getApplicationContext(), "Attempting connection", Toast.LENGTH_SHORT).show();
|
|
||||||
terminate = false;
|
terminate = false;
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
||||||
//int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
||||||
int connection_type = 1;
|
|
||||||
switch(connection_type) {
|
switch(connection_type) {
|
||||||
case 0: // No connection
|
case 0: // No connection
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
|
Toast.makeText(getApplicationContext(), "Attempting fake connection", Toast.LENGTH_SHORT).show();
|
||||||
activeTelem = new FakeTelemetryThread();
|
activeTelem = new FakeTelemetryThread();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
Toast.makeText(getApplicationContext(), "Attempting BT connection", Toast.LENGTH_SHORT).show();
|
||||||
activeTelem = new BTTelemetryThread();
|
activeTelem = new BTTelemetryThread();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
Toast.makeText(getApplicationContext(), "Attempting TCP connection", Toast.LENGTH_SHORT).show();
|
||||||
|
activeTelem = new TcpTelemetryThread();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new Error("Unsupported");
|
throw new Error("Unsupported");
|
||||||
}
|
}
|
||||||
activeTelem.start();
|
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) {
|
void postNotification(int id, String message) {
|
||||||
String ns = Context.NOTIFICATION_SERVICE;
|
String ns = Context.NOTIFICATION_SERVICE;
|
||||||
NotificationManager mNManager = (NotificationManager) getSystemService(ns);
|
NotificationManager mNManager = (NotificationManager) getSystemService(ns);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user