[Title] change selection listener and modify event id
authorjihye kim <jihye1128.kim@samsung.com>
Thu, 10 May 2012 08:09:31 +0000 (17:09 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Thu, 10 May 2012 08:09:31 +0000 (17:09 +0900)
[Type] work
[Module] event injector
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

org.tizen.device/src/org/tizen/device/battery/page/BatteryPage.java
org.tizen.device/src/org/tizen/device/earjack/page/EarjackPage.java
org.tizen.device/src/org/tizen/device/rssi/page/RssiPage.java
org.tizen.device/src/org/tizen/device/usb/page/UsbPage.java
org.tizen.injector/src/org/tizen/injector/socket/TelephonySocket.java
org.tizen.injector/src/org/tizen/injector/view/InjectorView.java
org.tizen.nfc/src/org/tizen/nfc/page/NfcPage.java
org.tizen.sensor.accelerometer/src/org/tizen/sensor/accelerometer/page/MobilePanel.java
org.tizen.sensor.light/src/org/tizen/sensor/light/page/LightPage.java
org.tizen.sensor.proximity/src/org/tizen/sensor/proximity/page/ProximityPage.java

index 85147eb..f3cfd0e 100644 (file)
@@ -203,21 +203,20 @@ public class BatteryPage extends AbstractInjectorPage implements ISelectionListe
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null)
-                       connect();
-               else if(currentDevice == null && selectedEntry.getName() == null)
-                       return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                sendMessage(sendData, sensorOn);
        }
index 8fbf3bb..c265083 100644 (file)
@@ -187,23 +187,20 @@ public class EarjackPage extends AbstractInjectorPage implements ISelectionListe
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
-                       disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null) {
-                       connect();
-               } else if(currentDevice == null && selectedEntry.getName() == null) {
-                       return;
-               } else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
+               if (selectedEntry == null) {
                        disconnect();
-                       connect();
-               } else if (currentDevice.getSerialNumber() == selectedEntry.getName()) {
-                       return;
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                sendMessage(earjack_status);
        }
index 74c548a..0423b41 100644 (file)
@@ -156,21 +156,20 @@ public class RssiPage extends AbstractInjectorPage implements ISelectionListener
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null)
-                       connect();
-               else if(currentDevice == null && selectedEntry.getName() == null)
-                       return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                sendLevelMessage(sendData);
        }
index 107b7a5..d1ef304 100644 (file)
@@ -152,23 +152,20 @@ public class UsbPage extends AbstractInjectorPage implements ISelectionListener
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null) {
-                       connect();
-               } else if(currentDevice == null && selectedEntry.getName() == null) {
-                       return;
-               } else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
-               } else if (currentDevice.getSerialNumber() == selectedEntry.getName()) {
-                       return;
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                if( sensorOn ) // On
                        sendMessage(1);
index 470e8f3..2434033 100644 (file)
@@ -67,7 +67,36 @@ public class TelephonySocket {
        private Receiver receiverThread;
        public boolean callWaiting = false;
        private IDevice currentDevice = null;
+
+       // Event ID
+       private static int lengthOfID = 10;
+       private static byte[] TELEPHONY = new byte[lengthOfID];
+       private static byte[] SENSOR    = new byte[lengthOfID];
+       private static byte[] LOCATION  = new byte[lengthOfID];
+       private static byte[] NFC               = new byte[lengthOfID];
        
+       private TelephonySocket () {
+               int i = 0;
+               for (byte b : new String("telephony\n").getBytes()) {
+                       TELEPHONY[i++] = b;
+               }
+
+               i = 0;
+               for (byte b : new String("sensor\n").getBytes()) {
+                       SENSOR[i++] = b;
+               }
+
+               i = 0;
+               for (byte b : new String("location\n").getBytes()) {
+                       LOCATION[i++] = b;
+               }
+
+               i = 0;
+               for (byte b : new String("nfc\n").getBytes()) {
+                       NFC[i++] = b;
+               }
+       }
+
        public void addInjectorReceiver(ArrayList<AbstractInjectorReceiver> list) {
                if (list == null)
                        return;
@@ -162,8 +191,7 @@ public class TelephonySocket {
 
        private void sendInitialize() throws IOException {
                try {
-                       String str = "telephony\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(TELEPHONY, 0, lengthOfID);
                        output.flush();
                        
                        byte[] abuf = { 0x04, 0x00, 0x40, 0x41 };
@@ -173,8 +201,8 @@ public class TelephonySocket {
                        byte[] bbuf = { 0x16, 0x00, 0x00, 0x00 };
                        output.write(bbuf);
                        output.flush();
-                       
-                       output.write(str.getBytes(), 0, str.length());
+
+                       output.write(TELEPHONY, 0, lengthOfID);
                        output.flush();
                        
                        byte[] cbuf = { 0x00, 0x00, 0x40, 0x47 };
@@ -195,8 +223,7 @@ public class TelephonySocket {
                if (!isConnected())
                        connect();
                try {
-                       String str = "telephony\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(TELEPHONY, 0, lengthOfID);
                        output.flush();
                        
                        byte[] buf = { 0x00, 0x00, 0x11, 0x5b };
@@ -217,8 +244,7 @@ public class TelephonySocket {
                        return;
 
                try{
-                       String str = "telephony\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(TELEPHONY, 0, lengthOfID);
                        output.flush();
                        
                        byte[] abuf = { 0x00, 0x00, 0x10, 0x01 };
@@ -244,8 +270,7 @@ public class TelephonySocket {
 
                boolean result = false;
                try {
-                       String str = "telephony\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(TELEPHONY, 0, lengthOfID);
                        output.flush();
                        
                        byte[] starter = sendObj.makeStarterPacket();
@@ -277,13 +302,12 @@ public class TelephonySocket {
 
                boolean result = false;
                try {
-                       String str = "sensor\n\n\n\n";
                        if(output != null)
                                output.flush();
                        else
                                return false;
-                       
-                       output.write(str.getBytes(), 0, str.length());
+
+                       output.write(SENSOR, 0, lengthOfID);
                        output.flush();
                        
                        byte[] next_packet_length = { (byte)sensorMsg.getBytes().length, 0x00, 0x00, 0x00 };
@@ -313,8 +337,7 @@ public class TelephonySocket {
 
                boolean result = false;
                try {
-                       String str = "location\n\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(LOCATION, 0, lengthOfID);
                        output.flush();
                        
                        byte[] next_packet_length = { (byte)locationMsg.getBytes().length, 0x00, 0x00, 0x00 };
@@ -344,19 +367,9 @@ public class TelephonySocket {
 
                boolean result = false;
                try {
-                       String str = "nfc\n\n\n\n\n\n\n";
-                       output.write(str.getBytes(), 0, str.length());
+                       output.write(NFC, 0, lengthOfID);
                        output.flush();
 
-                       /*
-                       String msgLen = Integer.toString(nfcMsg.getBytes().length);
-                       while(msgLen.length() < 5)
-                       {
-                               msgLen = msgLen + "\n";
-                       }
-                       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();
@@ -364,7 +377,6 @@ public class TelephonySocket {
                        byte[] main = nfcMsg.getBytes();
                        if (main.length > 0)
                        {
-//                             ByteUtil.printHex(main, "send body");
                                output.write(main, 0, main.length);
                        }
                        output.flush();
index 01f2b4a..3d12441 100644 (file)
@@ -72,9 +72,11 @@ ISelectionListener {
 \r
        public final static String VIEW_ID = "org.tizen.injector.view.InjectorView";\r
 \r
+       /*\r
        private String errorMessage = Messages.InjectorView_6\r
                        + System.getProperty("line.separator") //$NON-NLS-1$\r
                        + Messages.InjectorView_8;\r
+       */\r
 \r
        private ArrayList<String> categoryList = new ArrayList<String>();\r
        private ArrayList<FormPageUtil> formUtilList = new ArrayList<FormPageUtil>();\r
@@ -331,7 +333,7 @@ ISelectionListener {
                if (desposing != true) {\r
                        job.schedule();\r
                }\r
-               */\r
+*/\r
        }\r
        \r
        public ArrayList<String> getCategoryList() {\r
@@ -371,23 +373,28 @@ ISelectionListener {
                } else if (!selectedEntry.getFileListingService().getDevice().isEmulator()) {\r
                        return;\r
                }\r
-               \r
+\r
                String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();\r
-               if(currentDevice == null && selectedName/*selectedEntry.getName()*/ != null)\r
-               {\r
-                       connect();\r
-                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
-               } else if (currentDevice.getSerialNumber() !=  selectedName/*selectedEntry.getName()*/) {\r
-                       disconnect_finished = false;\r
-                       disconnect();\r
-                       connect();\r
-                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
-               } else if(activated == false)\r
+               if(currentDevice == null)\r
                {\r
-                       connect();\r
-                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
-               } else if (currentDevice.getSerialNumber() ==  selectedName/*selectedEntry.getName()*/) {\r
-                       return;\r
+                       if (selectedName/*selectedEntry.getName()*/ != null) {\r
+                               connect();\r
+                               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       }\r
+               } else {\r
+                       if (currentDevice.getSerialNumber() !=  selectedName/*selectedEntry.getName()*/) {\r
+                               disconnect_finished = false;\r
+                               disconnect();\r
+                               connect();\r
+                               currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                       } else {\r
+                               if(activated == false) {\r
+                                       connect();\r
+                                       currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();\r
+                               } else {\r
+                                       return;\r
+                               }\r
+                       }\r
                }\r
 \r
                notifySelectionListeners(selectedEntry);\r
index f06a9b6..a3e89ee 100644 (file)
@@ -297,20 +297,17 @@ public class NfcPage extends AbstractInjectorPage implements ISelectionListener
        {
                if (selectedEntry == null) {
                        disconnect();
-                       return;
-               } else if (!selectedEntry.getFileListingService().getDevice().isEmulator()) {
-                       return;
-               }
-
-               String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
-               if (currentDevice == null) {
-                       if (selectedName != null) {
-                               connect();
-                       }
                } else {
-                       if (currentDevice.getSerialNumber() != selectedName) {
-                               disconnect();
-                               connect();
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
                        }
                }
        }
index 601585d..c3b2175 100644 (file)
@@ -949,21 +949,20 @@ private void updateSensorGyro(){
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null)
-                       connect();
-               else if(currentDevice == null && selectedEntry.getName() == null)
-                       return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
        }
 }
index dbf9d45..b70a243 100644 (file)
@@ -176,21 +176,20 @@ public class LightPage extends AbstractInjectorPage implements ISelectionListene
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null)
-                       connect();
-               else if(currentDevice == null && selectedEntry.getName() == null)
-                       return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                sendMessage(1, levelData);
                sendMessage(2, luxData);
index a158de1..f886afc 100644 (file)
@@ -160,21 +160,20 @@ public class ProximityPage extends AbstractInjectorPage implements ISelectionLis
 
        @Override
        public void selectionChanged(FileEntry selectedEntry) {
-               if( selectedEntry == null)
-               {
+               if (selectedEntry == null) {
                        disconnect();
-                       return;
-               }
-               else if (!selectedEntry.getFileListingService().getDevice().isEmulator())
-                       return;
-               
-               if(currentDevice == null && selectedEntry.getName() != null)
-                       connect();
-               else if(currentDevice == null && selectedEntry.getName() == null)
-                       return;
-               else if (currentDevice.getSerialNumber() != selectedEntry.getName()) {
-                       disconnect();
-                       connect();
+               } else {
+                       String selectedName = selectedEntry.getFileListingService().getDevice().getSerialNumber();
+                       if (currentDevice == null) {
+                               if (selectedName != null) {
+                                       connect();
+                               }
+                       } else {
+                               if (currentDevice.getSerialNumber() != selectedName) {
+                                       disconnect();
+                                       connect();
+                               }
+                       }
                }
                sendMessage(sendData);
        }