Various fixes for the Android resource container extension
authorMarkus Jung <markus.jung@samsung.com>
Tue, 22 Dec 2015 05:42:35 +0000 (14:42 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 22 Dec 2015 15:05:44 +0000 (15:05 +0000)
- Fixed configuration API
- Fixed JNI headers
- License statement fix
- Additional logging statements
- Additional example sensor resources

Change-Id: I28a6fa727f9c4ff90fc46d5ae159d247e7cf9dc4
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4695
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
14 files changed:
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/AndroidBundleSoftSensorResource.java
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsBundleInfo.java
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceAttributes.java
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceContainer.java
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsResourceContainerBundleAPI.java
service/resource-container/android/resource-container/src/main/java/org/iotivity/service/resourcecontainer/RcsValue.java
service/resource-container/android/resource-container/src/main/jni/AndroidResource.cpp
service/resource-container/android/resource-container/src/main/jni/JniRcsResourceContainer.cpp
service/resource-container/android/resource-container/src/main/jni/JniRcsResourceContainer.h
service/resource-container/examples/ContainerSample.cpp
service/resource-container/examples/android/AndroidBundle/app/src/main/java/org/iotivity/service/sample/androidbundle/resources/GyroscopeResource.java [new file with mode: 0644]
service/resource-container/examples/android/ContainerSampleApp/app/src/main/assets/lib/ResourceContainerConfig.xml
service/resource-container/src/Configuration.cpp
service/resource-container/src/ResourceContainerImpl.cpp

index 2f52867..5fe5a19 100644 (file)
@@ -1,3 +1,24 @@
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+
 package org.iotivity.service.resourcecontainer;
 
 import java.util.HashMap;
index 952239f..11e3112 100644 (file)
@@ -1,22 +1,23 @@
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 
 /**
  * @file
index 678387d..453716d 100644 (file)
@@ -1,22 +1,23 @@
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 
 package org.iotivity.service.resourcecontainer;
 
index 06cd652..53401cf 100644 (file)
@@ -1,22 +1,23 @@
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 
 /**
  * @file
@@ -141,7 +142,7 @@ public class RcsResourceContainer implements RcsResourceContainerBundleAPI {
                     }
                 }
                 catch(Exception e){
-                    Log.e(TAG, e.getMessage());
+                    Log.e(TAG, e.getMessage(), e);
                 }
                 Log.d(TAG, "Have to register android bundle");
             }
@@ -276,6 +277,7 @@ public class RcsResourceContainer implements RcsResourceContainerBundleAPI {
     }
 
     public void registerResource(String bundleId, AndroidBundleResource resource){
+        Log.d(TAG, "register Resource");
         // bundleResources.add(resource);
         nativeRegisterAndroidResource(resource, resource.getAttributeKeys(), bundleId,
                         resource.getURI(), resource.getResourceType(),
@@ -283,7 +285,9 @@ public class RcsResourceContainer implements RcsResourceContainerBundleAPI {
     }
     
     public List<ResourceConfig> getConfiguredBundleResources(String bundleId) {
+        Log.d(TAG, "getConfiguredBundleResource " + bundleId);
         int configuredResources = getNumberOfConfiguredResources(bundleId);
+        Log.d(TAG, "configured resources " + configuredResources);
 
         Vector<ResourceConfig> configs = new Vector<ResourceConfig>();
 
@@ -298,14 +302,17 @@ public class RcsResourceContainer implements RcsResourceContainerBundleAPI {
 
     
     public void unregisterResource(AndroidBundleResource resource){
+        Log.d(TAG, "unregister Resource");
         nativeUnregisterAndroidResource(resource, resource.getURI());
     }
 
     public int getNumberOfConfiguredResources(String bundleId){
+        Log.d(TAG, "getNumberOfConfiguredResources");
         return nativeGetNumberOfConfiguredResources(bundleId);
     }
 
     public String[] getConfiguredResourceParams(String bundleId, int resId){
+        Log.d(TAG, "getConfiguredResourceParams");
         return nativeGetConfiguredResourceParams(bundleId, resId);
     }
 }
index 075c39d..11a5e52 100644 (file)
@@ -1,22 +1,23 @@
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 
 /**
  * @file
@@ -28,7 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Vector;
 
-// TODO null check for parameters
 /**
  * This class provides APIs for managing the container and bundles in the
  * container.
index 56bf9dc..f21ccc9 100644 (file)
@@ -1,22 +1,22 @@
-/******************************************************************
- *
- * Copyright 2015 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 package org.iotivity.service.resourcecontainer;
 
index 46ec01a..6f0bfa5 100644 (file)
@@ -89,7 +89,7 @@ AndroidResource::AndroidResource(JNIEnv *env, jobject obj, jobject bundleResourc
             "handleGetAttributesRequest", "()Lorg/iotivity/service/resourcecontainer/RcsResourceAttributes;");
     //LOGD("Looking for softSensorResource class.");
     //jclass androidBundleSoftSensorResourceClass = m_env->FindClass("org/iotivity/service/resourcecontainer/AndroidBundleSoftSensorResource");
-    LOGD("Looking for onUpdatedInputResource2.");
+    LOGD("Looking for onUpdatedInputResource.");
     jclass superclass = m_env->GetSuperclass(m_bundleResourceClass);
 
     jclass classClass = m_env->FindClass("java/lang/Class");
index 2e0d048..c207cde 100644 (file)
@@ -311,24 +311,26 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeRegisterA
 (JNIEnv *env, jobject obj, jobject bundleResource, jobjectArray attributes, jstring bundleId,
  jstring uri, jstring resourceType, jstring res_name)
 {
+    JNIEnvWrapper envWrapper(env);
     LOGD("nativeRegisterAndroidResource");
-    const char *str_bundleId = env->GetStringUTFChars(bundleId, 0);
-    LOGD("retrieved bundle id.");
-    const char *str_uri = env->GetStringUTFChars(uri, 0);
-    LOGD("retrieved uri.");
-    const char *str_resourceType = env->GetStringUTFChars(resourceType, 0);
-    LOGD("retrieved resource type");
-    const char *str_res_name = env->GetStringUTFChars(res_name, 0);
+    auto str_bundle_id = toStdString(&envWrapper, bundleId);
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved bundle id: %s.", str_bundle_id.c_str());
+    auto str_uri = toStdString(&envWrapper, uri);
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved uri: %s.", str_uri.c_str());
+    auto str_resourceType = toStdString(&envWrapper, resourceType);
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved resource type: %s.", str_resourceType.c_str());
+    auto str_res_name = toStdString(&envWrapper, res_name);
     LOGD("retrieved res name.");
     AndroidResource res;
 
     BundleResource::Ptr androidResource = std::make_shared< AndroidResource >
-            (env, obj, bundleResource, str_bundleId, attributes);
+            (env, obj, bundleResource, str_bundle_id, attributes);
     ResourceContainerImpl *container = ResourceContainerImpl::getImplInstance();
 
-    androidResource->m_uri = string(str_uri, strlen(str_uri));
-    androidResource->m_resourceType = string(str_resourceType, strlen(str_resourceType));
-    androidResource->m_name = string(str_res_name, strlen(str_res_name));
+    androidResource->m_uri = str_uri;
+    androidResource->m_resourceType = str_resourceType;
+    androidResource->m_name = str_res_name;
+    androidResource->m_bundleId = str_bundle_id;
 
     // link java resource instance to c++ resource instance
     env->SetLongField(bundleResource, g_field_mNativeHandle, reinterpret_cast< jlong >(androidResource.get()));
@@ -369,8 +371,10 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeGetNumber
     JNIEnv *env, jobject obj, jstring bundleId)
 {
     (void)obj;
+    LOGD("nativeGetNumberOfConfiguredResources");
     const char *str_bundleId = env->GetStringUTFChars(bundleId, 0);
-
+    LOGD("retrieved bundle id");
+    __android_log_print(ANDROID_LOG_DEBUG, "CONTAINER", "getNumberOfConfiguredResources %s",str_bundleId);
     ResourceContainerImpl *container = ResourceContainerImpl::getImplInstance();
     vector< resourceInfo > resourceConfig;
     container->getResourceConfiguration(str_bundleId, &resourceConfig);
index aac1fc5..79eaae4 100644 (file)
@@ -83,12 +83,12 @@ JNIEXPORT void JNICALL Java_org_iotivity_service_resourcecontainer_RcsResourceCo
   (JNIEnv *, jobject, jobject, jobjectArray, jstring, jstring, jstring, jstring);
 
 JNIEXPORT void JNICALL Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeUnregisterAndroidResource
-  (JNIEnv *, jobject, jstring, jobject, jstring);
+  (JNIEnv *, jobject, jobject, jstring);
 
 JNIEXPORT jint JNICALL Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeGetNumberOfConfiguredResources
   (JNIEnv *, jobject,  jstring);
 
-JNIEXPORT jobjectArray JNICALL Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeBaseActivator_getConfiguredResourceParams
+JNIEXPORT jobjectArray JNICALL Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeGetConfiguredResourceParams
   (JNIEnv *, jobject, jstring, jint);
 
 
index 5d029b9..c6a5a00 100644 (file)
@@ -33,14 +33,6 @@ using OC::oc_log_stream;
 
 #define MAX_PATH 2048
 
-/* Annother way to create a context: */
-auto info_logger = []() -> boost::iostreams::stream<OC::oc_log_stream> &
-{
-    static OC::oc_log_stream ols(oc_make_ostream_logger);
-    static boost::iostreams::stream<OC::oc_log_stream> os(ols);
-
-    return os;
-};
 
 void getCurrentPath(std::string *pPath)
 {
@@ -64,10 +56,8 @@ void getCurrentPath(std::string *pPath)
 
 int main()
 {
-    info_logger()->set_module("ContainerTest");
-    info_logger()->set_level(OC_LOG_INFO);
 
-    info_logger() << "Starting container test." << std::flush;
+    cout << "Starting container test." << endl;
 
     std::string strConfigPath;
     getCurrentPath(&strConfigPath);
diff --git a/service/resource-container/examples/android/AndroidBundle/app/src/main/java/org/iotivity/service/sample/androidbundle/resources/GyroscopeResource.java b/service/resource-container/examples/android/AndroidBundle/app/src/main/java/org/iotivity/service/sample/androidbundle/resources/GyroscopeResource.java
new file mode 100644 (file)
index 0000000..1dfbeb2
--- /dev/null
@@ -0,0 +1,87 @@
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+package org.iotivity.service.sample.androidbundle.resources;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.util.Log;
+
+import org.iotivity.service.resourcecontainer.AndroidBundleResource;
+import org.iotivity.service.resourcecontainer.RcsResourceAttributes;
+import org.iotivity.service.resourcecontainer.RcsValue;
+
+public class GyroscopeResource extends AndroidBundleResource implements SensorEventListener {
+    private static final String LOG_TAG = GyroscopeResource.class.getSimpleName();
+    private final SensorManager mSensorManager;
+    private final Sensor humiditySensor;
+
+    public GyroscopeResource(Context context){
+        super(context);
+        this.setResourceType("oic.r.gyroscope");
+        this.setName("gyroscopeSensor");
+        mSensorManager = (SensorManager) context.getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
+        humiditySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
+        mSensorManager.registerListener(this, humiditySensor, SensorManager.SENSOR_DELAY_NORMAL);
+        Log.d(LOG_TAG, "Created new gyroscope instance");
+    }
+
+    @Override
+    protected void initAttributes() {
+        this.m_attributes.put("x", 0d);
+        this.m_attributes.put("y", 0d);
+        this.m_attributes.put("z", 0d);
+    }
+
+    @Override
+    public void handleSetAttributesRequest(RcsResourceAttributes attrs) {
+        Log.i(LOG_TAG, "Set Attributes called with ");
+        for(String key: attrs.keySet()){
+            Log.i(LOG_TAG, " " + key + ": " + attrs.get(key));
+        }
+    }
+
+    @Override
+    public RcsResourceAttributes handleGetAttributesRequest() {
+        Log.i(LOG_TAG, "Get Attributes called");
+        Log.i(LOG_TAG, "Returning: ");
+        for(String key: m_attributes.keySet()){
+            Log.i(LOG_TAG, " " + key + ": " + m_attributes.get(key));
+        }
+        return this.m_attributes;
+    }
+
+    @Override
+    public void onSensorChanged(SensorEvent sensorEvent) {
+        Log.i(LOG_TAG, "Sensor event " + sensorEvent.values[0] + ", " + sensorEvent.values[1]
+            + ", " + sensorEvent.values[2]);
+        setAttribute("x", new RcsValue( (int) (sensorEvent.values[0])), true);
+        setAttribute("y", new RcsValue( (int) (sensorEvent.values[1]) ) , true);
+        setAttribute("z", new RcsValue( (int) (sensorEvent.values[2]) ) , true);
+    }
+
+    @Override
+    public void onAccuracyChanged(Sensor sensor, int i) {
+
+    }
+}
index ba1972f..da6e17f 100755 (executable)
@@ -38,7 +38,7 @@
         </resources>
     </bundle>
     <bundle>
-        <id>oic.bundle.android.light</id>
+        <id>oic.android.sample</id>
         <path>org.iotivity.service.sample.androidbundle.apk</path>
         <activator>org.iotivity.service.sample.androidbundle.SampleActivator</activator>
         <version>1.0.0</version>
                 <resourceUri>/android/light/1</resourceUri>
             </resourceInfo>
             <resourceInfo>
-                <name>LightIntensity1</name>
-                <resourceType>oic.r.lightintensity</resourceType>
-                <resourceUri>/android/lightintensity/1</resourceUri>
+                 <name>LightIntensity1</name>
+                 <resourceType>oic.r.lightintensity</resourceType>
+                 <resourceUri>/android/lightintensity/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Humidity1</name>
+                <resourceType>oic.r.humidity</resourceType>
+                <resourceUri>/android/humidity/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Tepmerature1</name>
+                <resourceType>oic.r.temperature</resourceType>
+                <resourceUri>/android/temperature/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Gyroscope1</name>
+                <resourceType>oic.r.gyroscope</resourceType>
+                <resourceUri>/android/gyroscope/1</resourceUri>
             </resourceInfo>
             <resourceInfo>
                 <name>DiscomfortIndexSensor1</name>
index e545c25..a4a2a44 100644 (file)
@@ -70,12 +70,15 @@ namespace OIC
 
         bool Configuration::isHasInput(std::string &bundleId) const
         {
+
             try
             {
+                OC_LOG_V(INFO, CONTAINER_TAG, "isHasInput: (%d) %s",m_mapisHasInput.at(bundleId), bundleId.c_str() );
                 return m_mapisHasInput.at(bundleId);
             }
             catch (std::out_of_range &e)
             {
+                OC_LOG_V(INFO, CONTAINER_TAG, "isHasInput out of range %s.", bundleId.c_str());
                 return false;
             }
         }
@@ -174,6 +177,7 @@ namespace OIC
 
             string strBundleId;
             string strKey, strValue;
+            OC_LOG(INFO, CONTAINER_TAG, "Loading resource configuration!");
 
             if (m_loaded)
             {
@@ -186,8 +190,11 @@ namespace OIC
                         // <id>
                         strBundleId = bundle->first_node(BUNDLE_ID)->value();
 
+                        OC_LOG_V(INFO, CONTAINER_TAG, "Comparing bundle ids %s - %s !", strBundleId.c_str(), bundleId.c_str());
+
                         if (!strBundleId.compare(bundleId))
                         {
+                            OC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
                             // <resourceInfo>
                             for (resource = bundle->first_node(OUTPUT_RESOURCES_TAG)->first_node(OUTPUT_RESOURCE_INFO);
                                  resource; resource = resource->next_sibling())
@@ -224,6 +231,7 @@ namespace OIC
                                             if (strKey.compare(INPUT_RESOURCE))
                                             {
                                                 m_mapisHasInput[strBundleId] = true;
+                                                OC_LOG_V(INFO, CONTAINER_TAG, "Bundle has input (%s)", strBundleId.c_str());
                                             }
 
                                             for (subItem2 = subItem->first_node(); subItem2;
@@ -252,6 +260,9 @@ namespace OIC
                     OC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
                 }
             }
+            else{
+                OC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
+            }
         }
 
         void Configuration::getConfigDocument(std::string pathConfigFile)
@@ -288,4 +299,4 @@ namespace OIC
             }
         }
     }
-}
\ No newline at end of file
+}
index 5cb86a7..fa09479 100644 (file)
@@ -220,12 +220,12 @@ namespace OIC
                 ((BundleInfoInternal *) bundleInfo)->setJavaBundle(false);
                 registerSoBundle(bundleInfo);
             }
+            // other cases might be for example .apk for android, which are loaded in the wrapper
             else{
                 ((BundleInfoInternal *) bundleInfo)->setSoBundle(false);
                 ((BundleInfoInternal *) bundleInfo)->setJavaBundle(false);
                 registerExtBundle(bundleInfo);
             }
-            // other cases might be for example .apk for android, which are loaded in the wrapper
         }
 
         void ResourceContainerImpl::unregisterBundle(RCSBundleInfo *bundleInfo)
@@ -273,8 +273,8 @@ namespace OIC
             string strResourceType = resource->m_resourceType;
             RCSResourceObject::Ptr server = nullptr;
 
-            OC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
-                     std::string(strUri + ", " + strResourceType).c_str());
+            OC_LOG_V(INFO, CONTAINER_TAG, "Registration of resource (%s)" ,
+                     std::string(strUri + ", " + strResourceType + "," + resource->m_bundleId).c_str());
 
             registrationLock.lock();
             if (m_mapResources.find(strUri) == m_mapResources.end())
@@ -295,14 +295,23 @@ namespace OIC
                         std::bind(&ResourceContainerImpl::setRequestHandler, this,
                                   std::placeholders::_1, std::placeholders::_2));
 
-                    OC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
-                             std::string(strUri + ", " +
-                                         strResourceType).c_str());
+
 
                     if (m_config->isHasInput(resource->m_bundleId))
                     {
+                        OC_LOG_V(INFO, CONTAINER_TAG, "Resource has input (%s)",
+                                                                        std::string(strUri + ", " +
+                                                                                    strResourceType).c_str());
                         discoverInputResource(strUri);
                     }
+                    else{
+                        OC_LOG_V(INFO, CONTAINER_TAG, "Resource has no input (%s)",
+                                                                                                std::string(strUri + ", " +
+                                                                                                            strResourceType).c_str());
+                    }
+                    OC_LOG_V(INFO, CONTAINER_TAG, "Registration finished (%s)",
+                                                std::string(strUri + ", " +
+                                                            strResourceType).c_str());
 
                     // to get notified if bundle resource attributes are updated
                     resource->registerObserver((NotificationReceiver *) this);
@@ -355,6 +364,9 @@ namespace OIC
             {
                 m_config->getResourceConfiguration(bundleId, configOutput);
             }
+            else{
+                OC_LOG_V(DEBUG, CONTAINER_TAG, "no config present ");
+            }
         }
 
         RCSGetResponse ResourceContainerImpl::getRequestHandler(const RCSRequest &request,
@@ -449,6 +461,7 @@ namespace OIC
 
         void ResourceContainerImpl::startBundle(const std::string &bundleId)
         {
+            OC_LOG_V(INFO, CONTAINER_TAG, "startBundle %s",bundleId.c_str());
             if (m_bundles.find(bundleId) != m_bundles.end())
             {
                 if (!m_bundles[bundleId]->isActivated())
@@ -467,6 +480,7 @@ namespace OIC
 
         void ResourceContainerImpl::stopBundle(const std::string &bundleId)
         {
+            OC_LOG_V(INFO, CONTAINER_TAG, "stopBundle %s",bundleId.c_str());
             if (m_bundles.find(bundleId) != m_bundles.end())
             {
                 if (m_bundles[bundleId]->isActivated())
@@ -516,6 +530,7 @@ namespace OIC
 
         void ResourceContainerImpl::removeBundle(const std::string &bundleId)
         {
+            OC_LOG_V(INFO, CONTAINER_TAG, "removeBundle %s",bundleId.c_str());
             if (m_bundles.find(bundleId) != m_bundles.end())
             {
                 BundleInfoInternal *bundleInfo = m_bundles[bundleId];
@@ -579,6 +594,7 @@ namespace OIC
         void ResourceContainerImpl::removeResourceConfig(const std::string &bundleId,
                 const std::string &resourceUri)
         {
+            OC_LOG_V(INFO, CONTAINER_TAG, "removeResourceConfig %s, %s",bundleId.c_str(), resourceUri.c_str());
             if (m_bundles.find(bundleId) != m_bundles.end())
             {
                 if (m_bundles[bundleId]->getSoBundle())
@@ -595,6 +611,7 @@ namespace OIC
 
         std::list< string > ResourceContainerImpl::listBundleResources(const std::string &bundleId)
         {
+            OC_LOG_V(INFO, CONTAINER_TAG, "listBundleResources %s",bundleId.c_str());
             std::list < string > ret;
 
             if (m_mapBundleResources.find(bundleId) != m_mapBundleResources.end())
@@ -709,6 +726,13 @@ namespace OIC
                                              std::string(bundleInfo->getActivatorName()).c_str());
 
             m_bundles[bundleInfo->getID()] = ((BundleInfoInternal *)bundleInfo);
+            // in this case at least the resource configuration needs to be loaded
+            // in order to mark potential input resources for soft sensors
+            std::vector< resourceInfo > temp;
+            OC_LOG_V(INFO, CONTAINER_TAG, "Loading resource config(%s)",
+                                                         std::string(bundleInfo->getID()).c_str());
+            getResourceConfiguration(bundleInfo->getID(),
+                            &temp);
 
             OC_LOG(INFO, CONTAINER_TAG, "Bundle registered");
         }