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);
output.write(str.getBytes(), 0, str.length());
output.flush();
+ /*
String msgLen = Integer.toString(nfcMsg.getBytes().length);
while(msgLen.length() < 5)
{
}
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)
{
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;
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);
}
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;
}