]> rtime.felk.cvut.cz Git - orte/eurobot.git/commitdiff
ROBOT_DEMO: use Manager class instead of ortemanager binary
authorMartin Vajnar <martin.vajnar@gmail.com>
Thu, 11 Jul 2013 11:46:23 +0000 (13:46 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 23 Sep 2013 09:06:25 +0000 (11:06 +0200)
orte/Robot_Demo/AndroidManifest.xml
orte/Robot_Demo/assets/ortemanager [deleted symlink]
orte/Robot_Demo/gen/org/ocera/orte/R.java
orte/Robot_Demo/gen/org/ocera/orte/demo/BuildConfig.java [moved from orte/Robot_Demo/gen/org/ocera/orte/BuildConfig.java with 81% similarity]
orte/Robot_Demo/gen/org/ocera/orte/demo/R.java [new file with mode: 0644]
orte/Robot_Demo/src/org/ocera/orte/demo/MainActivity.java

index da78332b8522334afc7a9ab612aac572e24ce5a8..8d2e61d1f74be72d6782525e8107b3afe52d5f79 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.ocera.orte"
+    package="org.ocera.orte.demo"
     android:versionCode="1"
     android:versionName="1.0" >
 
     
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
-    <uses-permission android:name="android.permission.SET_DEBUG_APP"/>
+
 
     <application
         android:allowBackup="true"
-        android:debuggable="true"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
diff --git a/orte/Robot_Demo/assets/ortemanager b/orte/Robot_Demo/assets/ortemanager
deleted file mode 120000 (symlink)
index fd09fd8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../libaorte/libs/armeabi-v7a/ortemanager
\ No newline at end of file
index 484402fb5ae9d736dc85dadc504bd0aa8f9c26c4..d6c47c682d8db7210e3d6a1395922acd88f789f5 100644 (file)
@@ -4,87 +4,17 @@
  * aapt tool from the resource data it found.  It
  * should not be modified by hand.
  */
-
 package org.ocera.orte;
 
 public final class R {
-    public static final class attr {
-    }
-    public static final class drawable {
-        public static final int ic_launcher=0x7f020000;
-    }
-    public static final class id {
-        public static final int button1=0x7f070000;
-        public static final int button2=0x7f070001;
-        public static final int button3=0x7f070002;
-        public static final int button4=0x7f070003;
-        public static final int menu_settings=0x7f070006;
-        public static final int scrollView1=0x7f070004;
-        public static final int textView1=0x7f070005;
-    }
-    public static final class layout {
-        public static final int activity_main=0x7f030000;
-    }
-    public static final class menu {
-        public static final int activity_main=0x7f060000;
-    }
-    public static final class string {
-        public static final int app_name=0x7f040000;
-        public static final int body1=0x7f040005;
-        public static final int button1_tab1=0x7f040002;
-        public static final int button1_tab2=0x7f040004;
-        public static final int button2_tab1=0x7f040003;
-        public static final int button2_tab2=0x7f040006;
-        public static final int menu_settings=0x7f040001;
-    }
-    public static final class style {
-        /** 
-        Base application theme, dependent on API level. This theme is replaced
-        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    
-
-            Theme customizations available in newer API levels can go in
-            res/values-vXX/styles.xml, while customizations related to
-            backward-compatibility can go here.
-        
-
-        Base application theme for API 11+. This theme completely replaces
-        AppBaseTheme from res/values/styles.xml on API 11+ devices.
-    
- API 11 theme customizations can go here. 
-
-        Base application theme for API 14+. This theme completely replaces
-        AppBaseTheme from BOTH res/values/styles.xml and
-        res/values-v11/styles.xml on API 14+ devices.
-    
- API 14 theme customizations can go here. 
-
-        Base application theme, dependent on API level. This theme is replaced
-        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    
-
-            Theme customizations available in newer API levels can go in
-            res/values-vXX/styles.xml, while customizations related to
-            backward-compatibility can go here.
-        
-
-        Base application theme for API 11+. This theme completely replaces
-        AppBaseTheme from res/values/styles.xml on API 11+ devices.
-    
- API 11 theme customizations can go here. 
-
-        Base application theme for API 14+. This theme completely replaces
-        AppBaseTheme from BOTH res/values/styles.xml and
-        res/values-v11/styles.xml on API 14+ devices.
-    
- API 14 theme customizations can go here. 
-         */
-        public static final int AppBaseTheme=0x7f050000;
-        /**  Application theme. 
- All customizations that are NOT specific to a particular API-level can go here. 
- Application theme. 
- All customizations that are NOT specific to a particular API-level can go here. 
-         */
-        public static final int AppTheme=0x7f050001;
-    }
+       public static final class drawable {
+               public static final int ic_launcher = 0x7f020000;
+       }
+       public static final class string {
+               public static final int app_name = 0x7f040000;
+       }
+       public static final class style {
+               public static final int AppBaseTheme = 0x7f050000;
+               public static final int AppTheme = 0x7f050001;
+       }
 }
similarity index 81%
rename from orte/Robot_Demo/gen/org/ocera/orte/BuildConfig.java
rename to orte/Robot_Demo/gen/org/ocera/orte/demo/BuildConfig.java
index 9113210231039bb8d9937f724fcc49e15a0e0881..7d1bf6fdf1ed187737d98beaa3fcf46be1424266 100644 (file)
@@ -1,5 +1,5 @@
 /** Automatically generated file. DO NOT MODIFY */
-package org.ocera.orte;
+package org.ocera.orte.demo;
 
 public final class BuildConfig {
     public final static boolean DEBUG = true;
diff --git a/orte/Robot_Demo/gen/org/ocera/orte/demo/R.java b/orte/Robot_Demo/gen/org/ocera/orte/demo/R.java
new file mode 100644 (file)
index 0000000..cd2435f
--- /dev/null
@@ -0,0 +1,90 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package org.ocera.orte.demo;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+    }
+    public static final class id {
+        public static final int button1=0x7f070000;
+        public static final int button2=0x7f070001;
+        public static final int button3=0x7f070002;
+        public static final int button4=0x7f070003;
+        public static final int menu_settings=0x7f070006;
+        public static final int scrollView1=0x7f070004;
+        public static final int textView1=0x7f070005;
+    }
+    public static final class layout {
+        public static final int activity_main=0x7f030000;
+    }
+    public static final class menu {
+        public static final int activity_main=0x7f060000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f040000;
+        public static final int body1=0x7f040005;
+        public static final int button1_tab1=0x7f040002;
+        public static final int button1_tab2=0x7f040004;
+        public static final int button2_tab1=0x7f040003;
+        public static final int button2_tab2=0x7f040006;
+        public static final int menu_settings=0x7f040001;
+    }
+    public static final class style {
+        /** 
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    
+
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        
+
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    
+ API 11 theme customizations can go here. 
+
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    
+ API 14 theme customizations can go here. 
+
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    
+
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        
+
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    
+ API 11 theme customizations can go here. 
+
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    
+ API 14 theme customizations can go here. 
+         */
+        public static final int AppBaseTheme=0x7f050000;
+        /**  Application theme. 
+ All customizations that are NOT specific to a particular API-level can go here. 
+ Application theme. 
+ All customizations that are NOT specific to a particular API-level can go here. 
+         */
+        public static final int AppTheme=0x7f050001;
+    }
+}
index 3b51c3673aed34ac044b88468505022badcf6069..c0055d5a623e793945cf394d1ff1189f87e82797 100644 (file)
@@ -1,15 +1,9 @@
 package org.ocera.orte.demo;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
 import org.ocera.orte.DomainApp;
 import org.ocera.orte.JOrte;
+import org.ocera.orte.Manager;
 import org.ocera.orte.Publication;
-import org.ocera.orte.R;
 import org.ocera.orte.types.DomainProp;
 import org.ocera.orte.types.NtpTime;
 import org.ocera.orte.types.ORTEConstant;
@@ -36,7 +30,7 @@ public class MainActivity extends Activity {
        Button start_pub = null;
        Button stop_pub = null;
        TextView textview = null;
-       Process manager = null;
+       Manager manager = null;
        Thread publisher = null;
        boolean tContinue = true;
        
@@ -119,35 +113,6 @@ public class MainActivity extends Activity {
                }
        }
        
-       public void copyManager() {
-               BufferedInputStream bis = null;
-               BufferedOutputStream bos = null;
-               
-               String path = getFilesDir().getAbsolutePath() + "/ortemanager";
-               
-               if (!new File(path).exists()) {
-                       try {
-                               bis = new BufferedInputStream(getAssets().open("ortemanager"));
-                               bos = new BufferedOutputStream(new FileOutputStream(path));
-                               
-                               int delka;
-                               byte[] buffer = new byte[4096];
-                               
-                               while((delka = bis.read(buffer, 0, 4096)) > 0) {
-                                       bos.write(buffer, 0, delka);
-                               }
-                               
-                               bos.flush();
-                               bos.close();
-                               bis.close();
-                               
-                               Runtime.getRuntime().exec("chmod 744 " + path);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       }
-               }
-       }
-       
     @Override
     protected void onResume() {
         super.onResume();
@@ -194,21 +159,16 @@ public class MainActivity extends Activity {
         mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());
        
         mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
-        
-        copyManager();
 
                start.setOnClickListener(new View.OnClickListener() {
-                   String[] orte = {getFilesDir().getAbsolutePath() + "/ortemanager","-p 192.168.1.5:192.168.1.8"};
+                   String[] mgrs = {"192.168.1.5","192.168.1.8"};
                        
                    @Override
                        public void onClick(View v) {
                                start.setEnabled(false);
                                stop.setEnabled(true);
-                               try {
-                                       manager = Runtime.getRuntime().exec(orte);
-                               } catch (IOException e) {
-                                       e.printStackTrace();
-                               }
+                               manager = new Manager(mgrs);
+                               
                                start_pub.setEnabled(true);
                        }
                });
@@ -221,7 +181,8 @@ public class MainActivity extends Activity {
                                stop.setEnabled(false);
                                start_pub.setEnabled(false);
                                stop_pub.setEnabled(false);
-                               manager.destroy();
+                               manager = null;
+                               System.gc();
                        }
                });