[Title] modify location event (SDB -> EMULD) and nfc event
authorjihye kim <jihye1128.kim@samsung.com>
Thu, 10 May 2012 02:47:34 +0000 (11:47 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Thu, 10 May 2012 02:47:34 +0000 (11:47 +0900)
need synchronization with emuld(emulator).
[Type] work
[Module] event injector
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.injector/src/org/tizen/injector/socket/TelephonySocket.java
org.tizen.location.core/src/org/tizen/location/core/injector/LocationInjector.java

index a5b48f9..470e8f3 100644 (file)
@@ -320,7 +320,7 @@ public class TelephonySocket {
                        byte[] next_packet_length = { (byte)locationMsg.getBytes().length, 0x00, 0x00, 0x00 };
                        output.write(next_packet_length);
                        output.flush();
-                       
+
                        byte[] main = locationMsg.getBytes();
                        if (main.length > 0) {
                                output.write(main, 0, main.length);
@@ -348,6 +348,7 @@ public class TelephonySocket {
                        output.write(str.getBytes(), 0, str.length());
                        output.flush();
 
+                       /*
                        String msgLen = Integer.toString(nfcMsg.getBytes().length);
                        while(msgLen.length() < 5)
                        {
@@ -355,7 +356,11 @@ public class TelephonySocket {
                        }
                        output.write(msgLen.getBytes(), 0 , msgLen.length());
                        output.flush();
-                       
+                       */
+                       byte[] next_packet_length = ByteUtil.int2byte(nfcMsg.getBytes().length);
+                       output.write(next_packet_length);
+                       output.flush();
+
                        byte[] main = nfcMsg.getBytes();
                        if (main.length > 0)
                        {
index c16f576..e323f2b 100644 (file)
@@ -41,6 +41,7 @@ import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.SyncService;
 import org.tizen.sdblib.SyncService.SyncResult;
 //import org.tizen.location.core.injector.DebugLog;
+import org.tizen.injector.socket.TelephonySocket;
 import org.tizen.injector.view.InjectorView;
 import org.tizen.location.core.model.GeoLocationVO;
 import org.tizen.location.core.protocol.GeoLocation;
@@ -49,12 +50,13 @@ public class LocationInjector implements ISelectionListener {
        private IProgressMonitor monitor;
 
        private final String remoteFilePath = "/opt/data/gps-manager/replay/nmea_replay.log";
-       private final String setStopMode        = "vconftool set -t int db/location/replay/ReplayMode 0"; // STOP MODE
-       private final String setLogMode         = "vconftool set -t int db/location/replay/ReplayMode 1"; // NMEA MODE(LOG MODE)
-       private final String setManualMode      = "vconftool set -t int db/location/replay/ReplayMode 2"; // MANUAL MODE
+       private final String SETSTOPMODE        = "0";//"vconftool set -t int db/location/replay/ReplayMode 0"; // STOP MODE
+       private final String SETLOGMODE         = "1";//"vconftool set -t int db/location/replay/ReplayMode 1"; // NMEA MODE(LOG MODE)
+       private final String SETMANUALMODE      = "2";//"vconftool set -t int db/location/replay/ReplayMode 2"; // MANUAL MODE
 
        private boolean isChange = false;
        private GeoLocation location = null;
+       private TelephonySocket injectorSocket = TelephonySocket.getInstance();
 
        public LocationInjector() {
                InjectorView.getDefault().addSelectionListener(this);
@@ -62,28 +64,39 @@ public class LocationInjector implements ISelectionListener {
        }
 
        private void setStopMode() throws IOException {
-               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
-               currentDevice.executeShellCommand(setStopMode);
+               try {
+                       injectorSocket.sendLocation(SETSTOPMODE);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
        }
 
        private void setLogMode() throws IOException {
-               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
-               currentDevice.executeShellCommand(setLogMode);
+               try {
+                       injectorSocket.sendLocation(SETLOGMODE);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
        }
        
        private void setManualMode() throws IOException {
-               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
-               currentDevice.executeShellCommand(setManualMode);
+               try {
+                       injectorSocket.sendLocation(SETMANUALMODE);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
        }
 
        private boolean injectLocation(double latitude, double longitude) throws IOException {
-               IDevice currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
-               String latitudeCmd  = String.format("vconftool set -t double db/location/replay/ManualLatitude %f", latitude);
-               String longitudeCmd = String.format("vconftool set -t double db/location/replay/ManualLongitude %f", longitude);
-
-               currentDevice.executeShellCommand(latitudeCmd);
-               currentDevice.executeShellCommand(longitudeCmd);
-
+               String location = latitude + "," + longitude;
+               //String latitudeCmd  = String.format("vconftool set -t double db/location/replay/ManualLatitude %f", latitude);
+               //String longitudeCmd = String.format("vconftool set -t double db/location/replay/ManualLongitude %f", longitude);
+               try {
+                       injectorSocket.sendLocation(location);
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       return false;
+               }
                return true;
        }