Fix Android Plugin code file
authorYounghyunJoo <yh_.joo@samsung.com>
Tue, 9 Jun 2015 07:34:07 +0000 (16:34 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 11 Jun 2015 12:06:39 +0000 (12:06 +0000)
For changed base code

Change-Id: If3a40333cb09a6c3bb2d6a01d275114a7ec45b14
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1225
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/protocol-plugin/plugins/Android/plugin.gear.noti/.project [new file with mode: 0644]
service/protocol-plugin/plugins/Android/plugin.gear.noti/src/oic/plugin/gear/noti/Activator.java
service/protocol-plugin/plugins/Android/plugin.gear.noti/src/oic/plugin/gear/noti/EntityHandlerNoti.java
service/protocol-plugin/plugins/Android/plugin.hue/.project [new file with mode: 0644]
service/protocol-plugin/plugins/Android/plugin.hue/src/oic/plugin/hue/Activator.java
service/protocol-plugin/plugins/Android/plugin.hue/src/oic/plugin/hue/EntityHandlerHue.java
service/protocol-plugin/plugins/Android/plugin.wemo/.project [new file with mode: 0644]
service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/Activator.java
service/protocol-plugin/plugins/Android/plugin.wemo/src/oic/plugin/wemo/EntityHandlerWemo.java

diff --git a/service/protocol-plugin/plugins/Android/plugin.gear.noti/.project b/service/protocol-plugin/plugins/Android/plugin.gear.noti/.project
new file mode 100644 (file)
index 0000000..728c962
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>plugin.gear.noti</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
index 1d95080..cc8d826 100644 (file)
@@ -125,6 +125,9 @@ public class Activator extends Activity implements BundleActivator,
                     "device.notify", "oc.mi.def", entitycb,
                     EnumSet.of(ResourceProperty.DISCOVERABLE));
         }
+        else{
+            Log.w(TAG, "Something Happened");
+        }
     }
 
     @Override
index a9b5d74..b283f2a 100644 (file)
@@ -22,6 +22,7 @@
 
 package oic.plugin.gear.noti;
 
+import java.util.EnumSet;
 import java.util.UUID;
 
 import oic.plugin.gear.noti.Activator.TemplateTypes;
@@ -69,29 +70,18 @@ public class EntityHandlerNoti implements OcPlatform.EntityHandler {
                         .getRequestHandle());
                 response.setResourceHandle(resourcerequest
                         .getResourceHandle());
-                Log.d("JUDO",
-                        "/******************************************************************************/");
-                Log.d("JUDO", "Name: "
-                        + resourcerequest.getResourceRepresentation()
-                                .getValueString("name"));
-                Log.d("JUDO", "Name: "
-                        + resourcerequest.getResourceRepresentation()
-                                .getValueString("power"));
-                Log.d("JUDO", "Name: "
-                        + resourcerequest.getResourceRepresentation()
-                                .getValueInt("brigthness"));
-                Log.d("JUDO", "Name: "
-                        + resourcerequest.getResourceRepresentation()
-                                .getValueInt("color"));
-                Log.d("JUDO",
-                        "/******************************************************************************/");
                 switch (requestType) {
                     case GET:
                         break;
                     case PUT:
+                    try {
                         textNoti = resourcerequest
                                 .getResourceRepresentation()
-                                .getValueString("power");
+                                .getValue("power");
+                    } catch (OcException e) {
+                        // TODO Auto-generated catch block
+                        Log.e(TAG, e.getMessage());
+                    }
                         perform(0);
                         break;
                     case POST:
@@ -99,13 +89,19 @@ public class EntityHandlerNoti implements OcPlatform.EntityHandler {
                 }
                 response.setErrorCode(200);
                 // representation.setUri("/a/galaxy/gear");
-                representation.setValueString("name",
-                        Activator.myNotify.m_name);
-                representation.setValueString("power",
-                        Activator.myNotify.m_power);
-                representation.setValueInt("brightness", 0);
-                representation.setValueInt("color", 0);
-                response.setResourceRepresentation(representation);
+                try {
+                    representation.setValue("name",
+                            Activator.myNotify.m_name);
+                    representation.setValue("power",
+                            Activator.myNotify.m_power);
+                    representation.setValue("brightness", 0);
+                    representation.setValue("color", 0);
+                    response.setResourceRepresentation(representation);
+                } catch (OcException e) {
+                    // TODO Auto-generated catch block
+                    Log.e(TAG, e.getMessage());
+                }
+                
                 try {
                     OcPlatform.sendResponse(response);
                 } catch (OcException e) {
diff --git a/service/protocol-plugin/plugins/Android/plugin.hue/.project b/service/protocol-plugin/plugins/Android/plugin.hue/.project
new file mode 100644 (file)
index 0000000..c04a197
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>plugin.hue</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
index 64f831c..e92093c 100644 (file)
@@ -230,7 +230,7 @@ public class Activator extends Activity implements BundleActivator {
                                                            System.currentTimeMillis());
 
                                            PlatformConfig cfg = new PlatformConfig(
-                                                   this,
+                                                   getApplicationContext(),
                                                    ServiceType.IN_PROC,
                                                    ModeType.CLIENT_SERVER,
                                                    "0.0.0.0", 0,
index 278d3de..e401d6d 100644 (file)
@@ -22,6 +22,7 @@
 
 package oic.plugin.hue;
 
+import java.util.EnumSet;
 import java.util.List;
 
 import org.iotivity.base.EntityHandlerResult;
@@ -95,22 +96,28 @@ public class EntityHandlerHue implements OcPlatform.EntityHandler {
                                 .getResourceCache().getAllLights();
                         for (PHLight light : mmyLights) {
                             PHLightState lightState = new PHLightState();
-                            String str = resourcerequest
-                                    .getResourceRepresentation()
-                                    .getValueString("power");
-                            if (str.equals("on")) {
-                                lightState.setOn(true);
-                                Activator.myLight.m_power = "on";
-                            } else if (str.equals("off")) {
-                                lightState.setOn(false);
-                                Activator.myLight.m_power = "off";
+                            try {
+                                String str = resourcerequest
+                                        .getResourceRepresentation()
+                                        .getValue("power");
+                                if (str.equals("on")) {
+                                    lightState.setOn(true);
+                                    Activator.myLight.m_power = "on";
+                                } else if (str.equals("off")) {
+                                    lightState.setOn(false);
+                                    Activator.myLight.m_power = "off";
+                                }
+                                int setHueValue = resourcerequest
+                                        .getResourceRepresentation()
+                                        .getValue("color");
+                                lightState.setHue(setHueValue);
+                                Activator.myLight.m_color = resourcerequest
+                                        .getResourceRepresentation()
+                                        .getValue("color");
+                            } catch (OcException e) {
+                                // TODO Auto-generated catch block
+                                Log.e(TAG, e.getMessage());
                             }
-                            lightState.setHue(resourcerequest
-                                    .getResourceRepresentation()
-                                    .getValueInt("color"));
-                            Activator.myLight.m_color = resourcerequest
-                                    .getResourceRepresentation()
-                                    .getValueInt("color");
                             mbridge.updateLightState(light, lightState);
                         }
                         break;
@@ -119,14 +126,19 @@ public class EntityHandlerHue implements OcPlatform.EntityHandler {
                 }
                 response.setErrorCode(200);
                 // representation.setUri("/a/huebulb");
-                representation.setValueString("name",
-                        Activator.myLight.m_name);
-                representation.setValueString("power",
-                        Activator.myLight.m_power);
-                representation.setValueInt("brightness",
-                        Activator.myLight.m_brightness);
-                representation.setValueInt("color",
-                        Activator.myLight.m_color);
+                try { 
+                    representation.setValue("name",
+                            Activator.myLight.m_name);
+                    representation.setValue("power",
+                            Activator.myLight.m_power);
+                    representation.setValue("brightness",
+                            Activator.myLight.m_brightness);
+                    representation.setValue("color",
+                            Activator.myLight.m_color);
+                } catch (OcException e) {
+                    // TODO Auto-generated catch block
+                    Log.e(TAG, e.getMessage());
+                }
                 response.setResourceRepresentation(representation);
                 try {
                     OcPlatform.sendResponse(response);
diff --git a/service/protocol-plugin/plugins/Android/plugin.wemo/.project b/service/protocol-plugin/plugins/Android/plugin.wemo/.project
new file mode 100644 (file)
index 0000000..e38bedf
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>plugin.wemo</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
index 42aa81e..6a8b465 100644 (file)
@@ -150,7 +150,7 @@ public class Activator extends Activity implements BundleActivator,
                                 .getWeMoDeviceByUDN(udn);
                         if ((listDevice != null) && (listDevice.isAvailable())) {
                             PlatformConfig cfg = new PlatformConfig(
-                                    this,
+                                    getApplicationContext(),
                                     ServiceType.IN_PROC,
                                     ModeType.CLIENT_SERVER, "0.0.0.0", 0,
                                     QualityOfService.LOW);
index 559cc21..679bd7c 100644 (file)
@@ -23,6 +23,7 @@
 package oic.plugin.wemo;
 
 import java.util.ArrayList;
+import java.util.EnumSet;
 
 import org.iotivity.base.EntityHandlerResult;
 import org.iotivity.base.OcException;
@@ -87,19 +88,25 @@ public class EntityHandlerWemo implements OcPlatform.EntityHandler {
                             String type = wemoDevice.getType();
                             if (type.equals(WeMoDevice.SWITCH)) {
                                 String newState = "";
-                                if (resourcerequest
-                                        .getResourceRepresentation()
-                                        .getValueString("power")
-                                        .equals("on")) {
-                                    Activator.mySmartPlug.m_power = "on";
-                                    newState = WeMoDevice.WEMO_DEVICE_ON;
-                                } else if (resourcerequest
-                                        .getResourceRepresentation()
-                                        .getValueString("power")
-                                        .equals("off")) {
-                                    Activator.mySmartPlug.m_power = "off";
-                                    newState = WeMoDevice.WEMO_DEVICE_OFF;
-                                }
+                                try {
+                                    if (resourcerequest
+                                            .getResourceRepresentation()
+                                            .getValue("power")
+                                            .equals("on")) {
+                                        Activator.mySmartPlug.m_power = "on";
+                                        newState = WeMoDevice.WEMO_DEVICE_ON;
+                                    } else if (resourcerequest
+                                                .getResourceRepresentation()
+                                                .getValue("power")
+                                                .equals("off")) {
+                                            Activator.mySmartPlug.m_power = "off";
+                                            newState = WeMoDevice.WEMO_DEVICE_OFF;
+                                        }
+                                    } catch (OcException e) {
+                                        // TODO Auto-generated catch block
+                                        Log.e(TAG, e.getMessage());
+                                    }
+
                                 Activator.mWeMoSDKContext.setDeviceState(
                                         newState, wemoDevice.getUDN());
                             }
@@ -110,12 +117,18 @@ public class EntityHandlerWemo implements OcPlatform.EntityHandler {
                 }
                 response.setErrorCode(200);
                 // representation.setUri("/a/wemo");
-                representation.setValueString("name",
-                        Activator.mySmartPlug.m_name);
-                representation.setValueString("power",
-                        Activator.mySmartPlug.m_power);
-                representation.setValueInt("brightness", 0);
-                representation.setValueInt("color", 0);
+                try {
+                    representation.setValue("name",
+                            Activator.mySmartPlug.m_name);
+                    representation.setValue("power",
+                            Activator.mySmartPlug.m_power);
+                    representation.setValue("brightness", 0);
+                    representation.setValue("color", 0);
+                } catch (OcException e) {
+                    // TODO Auto-generated catch block
+                    Log.e(TAG, e.getMessage());
+                }
+                
                 response.setResourceRepresentation(representation);
                 try {
                     OcPlatform.sendResponse(response);