Throw OcException for invalid (null) parameters in Java Layer of android_api.
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcPlatform.java
index fc562be..589bdf1 100644 (file)
@@ -1,37 +1,38 @@
 /*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.base;
 
 import org.iotivity.ca.CaInterface;
+import org.iotivity.base.BuildConfig;
 
 import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
 
 /**
- * Contains the main entrance/functionality of the product. To set a custom configuration, the
- * implementer must make a call to OcPlatform.Configure before the first usage of a function in this
- * class.
+ * This class contains the main entrance/functionality of the product. To set a custom
+ * configuration, the implementer must make a call to OcPlatform.Configure before the first usage
+ * of a method in this class.
  */
 public final class OcPlatform {
 
@@ -40,6 +41,10 @@ public final class OcPlatform {
         System.loadLibrary("octbstack");
         System.loadLibrary("connectivity_abstraction");
         System.loadLibrary("oc");
+        if (0 != BuildConfig.SECURED)
+        {
+            System.loadLibrary("ocprovision");
+        }
         System.loadLibrary("ocstack-jni");
     }
 
@@ -64,27 +69,30 @@ public final class OcPlatform {
     public static final String GROUP_INTERFACE = "oic.mi.grp";
 
     public static final String WELL_KNOWN_QUERY = "/oic/res";
-    public static final String MULTICAST_PREFIX = "224.0.1.187:5683";
-    public static final String MULTICAST_IP = "224.0.1.187";
-    public static final int MULTICAST_PORT = 5683;
+    public static final String WELL_KNOWN_DEVICE_QUERY = "/oic/d";
+    public static final String WELL_KNOWN_PLATFORM_QUERY = "/oic/p";
     public static final int DEFAULT_PRESENCE_TTL = 60;
-    public static final String DEVICE_URI = "/oic/d";
     public static final String PRESENCE_URI = "/oic/ad";
 
     private static volatile boolean sIsPlatformInitialized = false;
+    private static QualityOfService sPlatformQualityOfService = QualityOfService.NA;
 
     private OcPlatform() {
     }
 
     /**
      * API for setting the configuration of the OcPlatform.
+     * <p>
      * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
+     * </p>
      *
      * @param platformConfig platform configuration
      */
     public synchronized static void Configure(PlatformConfig platformConfig) {
         if (!sIsPlatformInitialized) {
-            CaInterface.initialize(platformConfig.getContext());
+            CaInterface.initialize(platformConfig.getActivity(), platformConfig.getContext());
+
+            sPlatformQualityOfService = platformConfig.getQualityOfService();
 
             OcPlatform.configure(
                     platformConfig.getServiceType().getValue(),
@@ -108,9 +116,12 @@ public final class OcPlatform {
 
     /**
      * API for notifying base that resource's attributes have changed.
+     * <p>
+     * Note: This API is for server side only.
+     * </p>
      *
      * @param ocResourceHandle resource handle of the resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void notifyAllObservers(
             OcResourceHandle ocResourceHandle) throws OcException {
@@ -123,10 +134,13 @@ public final class OcPlatform {
 
     /**
      * API for notifying base that resource's attributes have changed.
+     * <p>
+     * Note: This API is for server side only.
+     * </p>
      *
      * @param ocResourceHandle resource handle of the resource
      * @param qualityOfService the quality of communication
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void notifyAllObservers(
             OcResourceHandle ocResourceHandle,
@@ -141,13 +155,16 @@ public final class OcPlatform {
 
     /**
      * API for notifying only specific clients that resource's attributes have changed.
+     * <p>
+     * Note: This API is for server side only.
+     * </p>
      *
      * @param ocResourceHandle    resource handle of the resource
      * @param ocObservationIdList These set of ids are ones which which will be notified upon
      *                            resource change.
      * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
      *                            this resource change
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void notifyListOfObservers(
             OcResourceHandle ocResourceHandle,
@@ -155,6 +172,10 @@ public final class OcPlatform {
             OcResourceResponse ocResourceResponse) throws OcException {
         OcPlatform.initCheck();
 
+        if (ocObservationIdList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocObservationIdList cannot be null");
+        }
+
         byte[] idArr = new byte[ocObservationIdList.size()];
         Iterator<Byte> it = ocObservationIdList.iterator();
         int i = 0;
@@ -175,6 +196,9 @@ public final class OcPlatform {
 
     /**
      * API for notifying only specific clients that resource's attributes have changed.
+     * <p>
+     * Note: This API is for server side only.
+     * </p>
      *
      * @param ocResourceHandle    resource handle of the resource
      * @param ocObservationIdList These set of ids are ones which which will be notified upon
@@ -182,7 +206,7 @@ public final class OcPlatform {
      * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
      *                            this resource change
      * @param qualityOfService    the quality of communication
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void notifyListOfObservers(
             OcResourceHandle ocResourceHandle,
@@ -191,6 +215,10 @@ public final class OcPlatform {
             QualityOfService qualityOfService) throws OcException {
         OcPlatform.initCheck();
 
+        if (ocObservationIdList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocObservationIdList cannot be null");
+        }
+
         byte[] idArr = new byte[ocObservationIdList.size()];
         Iterator<Byte> it = ocObservationIdList.iterator();
         int i = 0;
@@ -213,16 +241,18 @@ public final class OcPlatform {
             int qualityOfService) throws OcException;
 
     /**
-     * API for Service and Resource Discovery. NOTE: This API applies to client side only
+     * API for Service and Resource Discovery
+     * <p>
+     * Note: This API is for client side only.
+     * </p>
      *
-     * @param host                    Host IP Address of a service to direct resource discovery query.
+     * @param host                    Host Address of a service to direct resource discovery query.
      *                                If empty, performs multicast resource discovery query
      * @param resourceUri             name of the resource. If null or empty, performs search for all
      *                                resource names
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
-     *                                IPV6, ALL
+     * @param connectivityTypeSet     Set of types of connectivity. Example: IP
      * @param onResourceFoundListener Handles events, success states and failure states.
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void findResource(
             String host,
@@ -253,17 +283,19 @@ public final class OcPlatform {
             OnResourceFoundListener onResourceFoundListener) throws OcException;
 
     /**
-     * API for Service and Resource Discovery. NOTE: This API applies to client side only
+     * API for Service and Resource Discovery.
+     * <p>
+     * Note: This API is for client side only.
+     * </p>
      *
      * @param host                    Host IP Address of a service to direct resource discovery query.
      *                                If empty, performs multicast resource discovery query
      * @param resourceUri             name of the resource. If null or empty, performs search for all
      *                                resource names
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
-     *                                IPV6, ALL
+     * @param connectivityTypeSet     Set of types of connectivity. Example: IP
      * @param onResourceFoundListener Handles events, success states and failure states.
      * @param qualityOfService        the quality of communication
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void findResource(
             String host,
@@ -300,10 +332,9 @@ public final class OcPlatform {
      *
      * @param host                  Host IP Address. If null or empty, Multicast is performed.
      * @param deviceUri             Uri containing address to the virtual device
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
-     *                              IPV6, ALL
+     * @param connectivityTypeSet   Set of types of connectivity. Example: IP
      * @param onDeviceFoundListener Handles events, success states and failure states.
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void getDeviceInfo(
             String host,
@@ -336,11 +367,10 @@ public final class OcPlatform {
      *
      * @param host                  Host IP Address. If null or empty, Multicast is performed.
      * @param deviceUri             Uri containing address to the virtual device
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
-     *                              IPV6, ALL
+     * @param connectivityTypeSet   Set of types of connectivity. Example: IP
      * @param onDeviceFoundListener Handles events, success states and failure states.
      * @param qualityOfService      the quality of communication
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void getDeviceInfo(
             String host,
@@ -376,10 +406,9 @@ public final class OcPlatform {
      *
      * @param host                    Host IP Address. If null or empty, Multicast is performed.
      * @param platformUri             Uri containing address to the platform
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
-     *                                IPV6, ALL
+     * @param connectivityTypeSet     Set of types of connectivity. Example: IP
      * @param onPlatformFoundListener Handles events, success states and failure states.
-     * @throws OcException
+     * @throws OcException if failure
      */
 
     public static void getPlatformInfo(
@@ -413,11 +442,10 @@ public final class OcPlatform {
      *
      * @param host                    Host IP Address. If null or empty, Multicast is performed.
      * @param platformUri             Uri containing address to the platform
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
-     *                                IPV6, ALL
+     * @param connectivityTypeSet     Set of types of connectivity. Example: IP
      * @param onPlatformFoundListener Handles events, success states and failure states.
      * @param qualityOfService        the quality of communication
-     * @throws OcException
+     * @throws OcException if failure
      */
 
     public static void getPlatformInfo(
@@ -450,11 +478,14 @@ public final class OcPlatform {
             int qualityOfService) throws OcException;
 
     /**
-     * This API registers a resource with the server NOTE: This API applies to server side only.
+     * This API registers a resource with the server
+     * <p/>
+     * Note: This API applies to server & client side.
+     * </P>
      *
      * @param ocResource The instance of OcResource with all data filled
      * @return resource handle
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static OcResourceHandle registerResource(
             OcResource ocResource) throws OcException {
@@ -467,6 +498,9 @@ public final class OcPlatform {
 
     /**
      * This API registers a resource with the server NOTE: This API applies to server side only.
+     * <p/>
+     * Note: This API applies to server side only.
+     * </P>
      *
      * @param resourceUri         The URI of the resource. Example: "a/light"
      * @param resourceTypeName    The resource type. Example: "light"
@@ -474,7 +508,7 @@ public final class OcPlatform {
      * @param entityHandler       entity handler.
      * @param resourcePropertySet indicates the property of the resource
      * @return resource handle
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static OcResourceHandle registerResource(
             String resourceUri,
@@ -509,31 +543,35 @@ public final class OcPlatform {
      * Register Device Info
      *
      * @param ocDeviceInfo object containing all the device specific information
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void registerDeviceInfo(
             OcDeviceInfo ocDeviceInfo) throws OcException {
         OcPlatform.initCheck();
         OcPlatform.registerDeviceInfo0(
-                ocDeviceInfo.getDeviceName()
+                ocDeviceInfo.getDeviceName(),
+                ocDeviceInfo.getDeviceTypes().toArray(
+                        new String[ocDeviceInfo.getDeviceTypes().size()]
+                )
         );
     }
 
     private static native void registerDeviceInfo0(
-            String deviceName
+            String deviceName,
+            String[] deviceTypes
     ) throws OcException;
 
     /**
      * Register Platform Info
      *
      * @param ocPlatformInfo object containing all the platform specific information
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void registerPlatformInfo(
             OcPlatformInfo ocPlatformInfo) throws OcException {
         OcPlatform.initCheck();
         OcPlatform.registerPlatformInfo0(
-                ocPlatformInfo.getPlatformID(),
+                ocPlatformInfo.getPlatformId(),
                 ocPlatformInfo.getManufacturerName(),
                 ocPlatformInfo.getManufacturerUrl(),
                 ocPlatformInfo.getModelNumber(),
@@ -559,7 +597,7 @@ public final class OcPlatform {
      *
      * @param ocResourceHandle This is the resource handle which we which to unregister from the
      *                         server
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void unregisterResource(
             OcResourceHandle ocResourceHandle) throws OcException {
@@ -576,7 +614,7 @@ public final class OcPlatform {
      *
      * @param ocResourceCollectionHandle handle to the collection resource
      * @param ocResourceHandle           handle to resource to be added to the collection resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void bindResource(
             OcResourceHandle ocResourceCollectionHandle,
@@ -595,12 +633,17 @@ public final class OcPlatform {
      * @param ocResourceCollectionHandle handle to the collection resource
      * @param ocResourceHandleList       reference to list of resource handles to be added to the
      *                                   collection resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void bindResources(
             OcResourceHandle ocResourceCollectionHandle,
             List<OcResourceHandle> ocResourceHandleList) throws OcException {
         OcPlatform.initCheck();
+
+        if (ocResourceHandleList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocResourceHandleList cannot be null");
+        }
+
         OcPlatform.bindResources0(
                 ocResourceCollectionHandle,
                 ocResourceHandleList.toArray(
@@ -617,7 +660,7 @@ public final class OcPlatform {
      *
      * @param ocResourceCollectionHandle handle to the collection resource
      * @param ocResourceHandle           resource handle to be unbound from the collection resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void unbindResource(
             OcResourceHandle ocResourceCollectionHandle,
@@ -636,12 +679,17 @@ public final class OcPlatform {
      * @param ocResourceCollectionHandle Handle to the collection resource
      * @param ocResourceHandleList       List of resource handles to be unbound from the collection
      *                                   resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void unbindResources(
             OcResourceHandle ocResourceCollectionHandle,
             List<OcResourceHandle> ocResourceHandleList) throws OcException {
         OcPlatform.initCheck();
+
+        if (ocResourceHandleList == null) {
+            throw new OcException(ErrorCode.INVALID_PARAM, "ocResourceHandleList cannot be null");
+        }
+
         OcPlatform.unbindResources0(
                 ocResourceCollectionHandle,
                 ocResourceHandleList.toArray(
@@ -658,7 +706,7 @@ public final class OcPlatform {
      *
      * @param ocResourceHandle handle to the resource
      * @param resourceTypeName new typename to bind to the resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void bindTypeToResource(
             OcResourceHandle ocResourceHandle,
@@ -676,7 +724,7 @@ public final class OcPlatform {
      *
      * @param ocResourceHandle      handle to the resource
      * @param resourceInterfaceName new interface to bind to the resource
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void bindInterfaceToResource(
             OcResourceHandle ocResourceHandle,
@@ -693,7 +741,7 @@ public final class OcPlatform {
      * Start Presence announcements.
      *
      * @param ttl time to live in seconds
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void startPresence(int ttl) throws OcException {
         OcPlatform.initCheck();
@@ -705,7 +753,7 @@ public final class OcPlatform {
     /**
      * Stop Presence announcements.
      *
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void stopPresence() throws OcException {
         OcPlatform.initCheck();
@@ -718,13 +766,12 @@ public final class OcPlatform {
      * Subscribes to a server's presence change events. By making this subscription, every time a
      * server adds/removes/alters a resource, starts or is intentionally stopped
      *
-     * @param host               The IP address/addressable name of the server to subscribe to
-     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,
-     *                           IPV6, ALL
-     * @param onPresenceListener listener that will receive notifications/subscription events
+     * @param host                The IP address/addressable name of the server to subscribe to
+     * @param connectivityTypeSet Set of types of connectivity. Example: IP
+     * @param onPresenceListener  listener that will receive notifications/subscription events
      * @return a handle object that can be used to identify this subscription request. It can be
      * used to unsubscribe from these events in the future
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static OcPresenceHandle subscribePresence(
             String host,
@@ -753,14 +800,13 @@ public final class OcPlatform {
      * Subscribes to a server's presence change events. By making this subscription, every time a
      * server adds/removes/alters a resource, starts or is intentionally stopped
      *
-     * @param host               The IP address/addressable name of the server to subscribe to
-     * @param resourceType       a resource type specified as a filter for subscription events.
-     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,
-     *                           IPV6, ALL
-     * @param onPresenceListener listener that will receive notifications/subscription events
+     * @param host                The IP address/addressable name of the server to subscribe to
+     * @param resourceType        a resource type specified as a filter for subscription events.
+     * @param connectivityTypeSet Set of types of connectivity. Example: IP
+     * @param onPresenceListener  listener that will receive notifications/subscription events
      * @return a handle object that can be used to identify this subscription request. It can be
      * used to unsubscribe from these events in the future
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static OcPresenceHandle subscribePresence(
             String host,
@@ -794,7 +840,7 @@ public final class OcPlatform {
      *
      * @param ocPresenceHandle the handle object provided by the subscribePresence call that
      *                         identifies this subscription
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void unsubscribePresence(
             OcPresenceHandle ocPresenceHandle) throws OcException {
@@ -806,6 +852,43 @@ public final class OcPlatform {
             OcPresenceHandle ocPresenceHandle) throws OcException;
 
     /**
+     * Subscribes to a server's device presence change events.
+     *
+     * @param host                The IP address/addressable name of the server to subscribe to.
+     * @param di                  Vector which can have the devices id.
+     * @param connectivityTypeSet Set of connectivity types, e.g. IP.
+     * @param onObserveListener   The handler method will be invoked with a map
+     *                            of attribute name and values.
+     * @return a handle object that can be used to identify this subscription request.
+     *         It can be used to unsubscribe from these events in the future.
+     * @throws OcException if failure.
+     */
+    public static OcPresenceHandle subscribeDevicePresence(
+            String host,
+            List<String> di,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            OcResource.OnObserveListener onObserveListener) throws OcException {
+        OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+                connTypeInt |= connType.getValue();
+        }
+        return OcPlatform.subscribeDevicePresence0(
+                host,
+                di.toArray(new String[di.size()]),
+                connTypeInt,
+                onObserveListener);
+    }
+
+    private static native OcPresenceHandle subscribeDevicePresence0(
+            String host,
+            String[] di,
+            int connectivityType,
+            OcResource.OnObserveListener onObserveListener) throws OcException;
+
+    /**
      * Creates a resource proxy object so that get/put/observe functionality can be used without
      * discovering the object in advance. Note that the consumer of this method needs to provide
      * all of the details required to correctly contact and observe the object. If the consumer
@@ -813,18 +896,17 @@ public final class OcPlatform {
      * Additionally, you can only create this object if OcPlatform was initialized to be a Client
      * or Client/Server.
      *
-     * @param host             a string containing a resolvable host address of the server holding
-     *                         the resource
-     * @param uri              the rest of the resource's URI that will permit messages to be
-     *                         properly routed.
-     *                         Example: /a/light
-     * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
-     *                         IPV6, ALL
-     * @param isObservable     a boolean containing whether the resource supports observation
-     * @param resourceTypeList a collection of resource types implemented by the resource
-     * @param interfaceList    a collection of interfaces that the resource supports/implements
+     * @param host                a string containing a resolvable host address of the server holding
+     *                            the resource
+     * @param uri                 the rest of the resource's URI that will permit messages to be
+     *                            properly routed.
+     *                            Example: /a/light
+     * @param connectivityTypeSet Set of types of connectivity. Example: IP
+     * @param isObservable        a boolean containing whether the resource supports observation
+     * @param resourceTypeList    a collection of resource types implemented by the resource
+     * @param interfaceList       a collection of interfaces that the resource supports/implements
      * @return new resource object
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static OcResource constructResourceObject(
             String host,
@@ -862,7 +944,7 @@ public final class OcPlatform {
      * Allows application entity handler to send response to an incoming request.
      *
      * @param ocResourceResponse resource response
-     * @throws OcException
+     * @throws OcException if failure
      */
     public static void sendResponse(OcResourceResponse ocResourceResponse)
             throws OcException {
@@ -874,11 +956,394 @@ public final class OcPlatform {
             throws OcException;
 
     /**
+     *  Method to find all devices which are eligible for direct pairing and return the list.
+     *
+     *  @param timeout timeout for discovering direct pair devices.
+     *  @param FindDirectPairingListener Callback function, which will receive the list of direct
+     *                                  pairable devices.
+     *  @throws OcException
+     */
+   public static native void findDirectPairingDevices(int timeout,
+            FindDirectPairingListener onFindDirectPairingListener) throws OcException;
+
+    /**
+     *  Method to get list of all paired devices for a given device.
+     *
+     *  @param GetDirectPairedListener Callback function, which will receive the list of direct
+     *                                 paired devices.
+     *  @throws OcException
+     */
+    public native void getDirectPairedDevices(GetDirectPairedListener onGetDirectPairedListener)
+        throws OcException;
+
+    /**
+     *  Method to perform direct pairing between two devices.
+     *
+     *  @param peer  Target peer
+     *  @param prmType Pairing Method to be used for Pairing
+     *  @param pin pin
+     *  @param DirectPairingListener Callback function, which will be called after
+     *                                      completion of direct pairing.
+     *  @throws OcException
+     */
+    public static void doDirectPairing(
+            OcDirectPairDevice peer,
+            OcPrmType prmType,
+            String pin,
+            DirectPairingListener onDirectPairingListener) throws OcException {
+
+        OcPlatform.doDirectPairing0(
+                peer,
+                prmType.getValue(),
+                pin,
+                onDirectPairingListener
+                );
+    }
+
+    private static native void doDirectPairing0(OcDirectPairDevice peer,
+            int pmSel, String pinNumber, DirectPairingListener onDirectPairingListener)
+    throws OcException;
+
+    /**
+     * API to publish resource to remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param onPublishResourceListener   Handles events, success states and failure states.
+     * @throws OcException if failure
+     */
+    public static void publishResourceToRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            OnPublishResourceListener onPublishResourceListener) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.publishResourceToRD0(
+                host,
+                connTypeInt,
+                onPublishResourceListener,
+                sPlatformQualityOfService.getValue()
+        );
+    }
+
+    /**
+     * API to publish resource to remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param onPublishResourceListener   Handles events, success states and failure states.
+     * @param qualityOfService            the quality of communication.
+     * @throws OcException if failure
+     */
+    public static void publishResourceToRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            OnPublishResourceListener onPublishResourceListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.publishResourceToRD0(
+                host,
+                connTypeInt,
+                onPublishResourceListener,
+                qualityOfService.getValue()
+        );
+    }
+
+    private static native void publishResourceToRD0(
+            String host,
+            int connectivityType,
+            OnPublishResourceListener onPublishResourceListener,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API to publish resource to remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param ocResourceHandleList        reference to list of resource handles to be published.
+     * @param onPublishResourceListener   Handles events, success states and failure states.
+     * @throws OcException if failure
+     */
+    public static void publishResourceToRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            List<OcResourceHandle> ocResourceHandleList,
+            OnPublishResourceListener onPublishResourceListener) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.publishResourceToRD1(
+                host,
+                connTypeInt,
+                ocResourceHandleList.toArray(
+                        new OcResourceHandle[ocResourceHandleList.size()]),
+                onPublishResourceListener,
+                sPlatformQualityOfService.getValue()
+        );
+    }
+
+    /**
+     * API to publish resource to remote resource-directory.
+     *
+     * @param host                        Host IP Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param ocResourceHandleList        reference to list of resource handles to be published.
+     * @param onPublishResourceListener   Handles events, success states and failure states.
+     * @param qualityOfService            the quality of communication
+     * @throws OcException if failure
+     */
+    public static void publishResourceToRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            List<OcResourceHandle> ocResourceHandleList,
+            OnPublishResourceListener onPublishResourceListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.publishResourceToRD1(
+            host,
+            connTypeInt,
+            ocResourceHandleList.toArray(
+                    new OcResourceHandle[ocResourceHandleList.size()]),
+            onPublishResourceListener,
+            qualityOfService.getValue()
+        );
+    }
+
+    private static native void publishResourceToRD1(
+            String host,
+            int connectivityType,
+            OcResourceHandle[] ocResourceHandleArray,
+            OnPublishResourceListener onPublishResourceListener,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API to delete resource from remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param onDeleteResourceListener    Handles events, success states and failure states.
+     * @throws OcException if failure
+     */
+    public static void deleteResourceFromRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            OnDeleteResourceListener onDeleteResourceListener) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.deleteResourceFromRD0(
+                host,
+                connTypeInt,
+                onDeleteResourceListener,
+                sPlatformQualityOfService.getValue()
+        );
+    }
+
+    /**
+     * API to delete resource from remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param onDeleteResourceListener    Handles events, success states and failure states.
+     * @param qualityOfService            the quality of communication.
+     * @throws OcException if failure
+     */
+    public static void deleteResourceFromRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            OnDeleteResourceListener onDeleteResourceListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.deleteResourceFromRD0(
+                host,
+                connTypeInt,
+                onDeleteResourceListener,
+                qualityOfService.getValue()
+        );
+    }
+
+    private static native void deleteResourceFromRD0(
+            String host,
+            int connectivityType,
+            OnDeleteResourceListener onDeleteResourceListener,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API to delete resource from remote resource-directory.
+     *
+     * @param host                        Host Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param ocResourceHandleList        reference to list of resource handles to be published.
+     * @param onDeleteResourceListener         Handles events, success states and failure states.
+     * @throws OcException if failure
+     */
+    public static void deleteResourceFromRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            List<OcResourceHandle> ocResourceHandleList,
+            OnDeleteResourceListener onDeleteResourceListener) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.deleteResourceFromRD1(
+                host,
+                connTypeInt,
+                ocResourceHandleList.toArray(
+                        new OcResourceHandle[ocResourceHandleList.size()]),
+                onDeleteResourceListener,
+                sPlatformQualityOfService.getValue()
+        );
+    }
+
+    /**
+     * API to delete resource from remote resource-directory.
+     *
+     * @param host                        Host IP Address of a service to publish resource.
+     * @param connectivityTypeSet         Set of types of connectivity. Example: IP
+     * @param ocResourceHandleList        reference to list of resource handles to be published.
+     * @param onDeleteResourceListener    Handles events, success states and failure states.
+     * @param qualityOfService            the quality of communication
+     * @throws OcException if failure
+     */
+    public static void deleteResourceFromRD(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet,
+            List<OcResourceHandle> ocResourceHandleList,
+            OnDeleteResourceListener onDeleteResourceListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType)) {
+                connTypeInt |= connType.getValue();
+            }
+        }
+
+        OcPlatform.deleteResourceFromRD1(
+            host,
+            connTypeInt,
+            ocResourceHandleList.toArray(
+                    new OcResourceHandle[ocResourceHandleList.size()]),
+            onDeleteResourceListener,
+            qualityOfService.getValue()
+        );
+    }
+
+    private static native void deleteResourceFromRD1(
+            String host,
+            int connectivityType,
+            OcResourceHandle[] ocResourceHandleArray,
+            OnDeleteResourceListener onDeleteResourceListener,
+            int qualityOfService) throws OcException;
+
+    /**
+     * An OnPublishResourceListener can be registered via the OcPlatform.publishResourceToRD call.
+     * Event listeners are notified asynchronously
+     */
+    public interface OnPublishResourceListener {
+        public void onPublishResourceCompleted(OcRepresentation ocRepresentation);
+        public void onPublishResourceFailed(Throwable ex);
+    }
+
+    /**
+     * An OnDeleteResourceListener can be registered via the OcPlatform.deleteResourceFromRD call.
+     * Event listeners are notified asynchronously
+     */
+    public interface OnDeleteResourceListener {
+        public void onDeleteResourceCompleted(int result);
+    }
+
+    /**
+     * An FindDirectPairingListener can be registered via the OcPlatform.findDirectPairingDevices call.
+     * Event listeners are notified asynchronously
+     */
+    public interface FindDirectPairingListener {
+        public void onFindDirectPairingListener(List<OcDirectPairDevice> ocPairedDeviceList);
+    }
+
+    /**
+     * Listerner to Get List of already Direct Paired devices.
+     * An GetDirectPairedListener can be registered via the OcPlatform.getDirectPairedDevices call.
+     * Event listeners are notified asynchronously
+     */
+    public interface GetDirectPairedListener {
+        public void onGetDirectPairedListener(List<OcDirectPairDevice> ocPairedDeviceList);
+    }
+
+    /**
+     * Listner to get result of doDirectPairing.
+     * An DirectPairingListener can be registered via the OcPlatform.doDirectPairing call.
+     * Event listeners are notified asynchronously
+     */
+    public interface DirectPairingListener {
+        public void onDirectPairingListener(String devId, int result);
+    }
+
+    /**
      * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
      * Event listeners are notified asynchronously
      */
     public interface OnResourceFoundListener {
         public void onResourceFound(OcResource resource);
+        public void onFindResourceFailed(Throwable ex, String uri);
     }
 
     /**
@@ -908,6 +1373,14 @@ public final class OcPlatform {
     /**
      * An EntityHandler can be registered via the OcPlatform.registerResource call.
      * Event listeners are notified asynchronously
+     *
+     * @note entityhandler callback :
+     * When you set specific return value like EntityHandlerResult.OK, SLOW
+     * and etc in entity handler callback,
+     * ocstack will be not send response automatically to client
+     * except for error return value like EntityHandlerResult.ERROR
+     * If you want to send response to client with specific result,
+     * sendResponse API should be called with the result value.
      */
     public interface EntityHandler {
         public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
@@ -919,4 +1392,49 @@ public final class OcPlatform {
                     "OcPlatform.Configure before any other API calls are permitted");
         }
     }
+
+    /**
+     * Gets platform quality of service
+     *
+     * @return quality of service
+     */
+    public static QualityOfService getPlatformQualityOfService() {
+        OcPlatform.initCheck();
+        return sPlatformQualityOfService;
+    }
+
+    /**
+     * Create an account manager object that can be used for doing request to account server.
+     * You can only create this object if OCPlatform was initialized to be a Client or
+     * Client/Server. Otherwise, this will return an empty shared ptr.
+     *
+     * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
+     *       methods of this object to work since device id is not generated on Client mode.
+     *
+     * @param host                Host IP Address of a account server.
+     * @param connectivityTypeSet Set of types of connectivity. Example: CT_ADAPTER_IP
+     * @return new AccountManager object
+     * @throws OcException if failure
+     */
+    public static OcAccountManager constructAccountManagerObject(
+            String host,
+            EnumSet<OcConnectivityType> connectivityTypeSet) throws OcException {
+        OcPlatform.initCheck();
+        int connTypeInt = 0;
+
+        for (OcConnectivityType connType : OcConnectivityType.values()) {
+            if (connectivityTypeSet.contains(connType))
+            {
+                connTypeInt |= connType.getValue();
+            }
+        }
+        return OcPlatform.constructAccountManagerObject0(
+                host,
+                connTypeInt
+                );
+    }
+
+    private static native OcAccountManager constructAccountManagerObject0(
+            String host,
+            int connectivityType) throws OcException;
 }