Merge "Merge branch 'master' into notification-service" into notification-service
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcPlatform.java
1 /*
2  *******************************************************************
3  *
4  * Copyright 2015 Intel Corporation.
5  *
6  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21  */
22
23 package org.iotivity.base;
24
25 import org.iotivity.ca.CaInterface;
26 import org.iotivity.base.BuildConfig;
27
28 import java.util.EnumSet;
29 import java.util.Iterator;
30 import java.util.List;
31
32 /**
33  * This class contains the main entrance/functionality of the product. To set a custom
34  * configuration, the implementer must make a call to OcPlatform.Configure before the first usage
35  * of a method in this class.
36  */
37 public final class OcPlatform {
38
39     static {
40         System.loadLibrary("oc_logger");
41         System.loadLibrary("octbstack");
42         System.loadLibrary("connectivity_abstraction");
43         System.loadLibrary("oc");
44         if (0 != BuildConfig.SECURED)
45         {
46             System.loadLibrary("ocprovision");
47         }
48         System.loadLibrary("ocstack-jni");
49     }
50
51     /**
52      * Default interface
53      */
54     public static final String DEFAULT_INTERFACE = "oic.if.baseline";
55
56     /**
57      * Used in discovering (GET) links to other resources of a collection
58      */
59     public static final String LINK_INTERFACE = "oic.if.ll";
60
61     /**
62      * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection
63      */
64     public static final String BATCH_INTERFACE = "oic.if.b";
65
66     /**
67      * Used in GET, PUT, POST methods on links to other remote resources of a group
68      */
69     public static final String GROUP_INTERFACE = "oic.mi.grp";
70
71     public static final String WELL_KNOWN_QUERY = "/oic/res";
72     public static final String WELL_KNOWN_DEVICE_QUERY = "/oic/d";
73     public static final String WELL_KNOWN_PLATFORM_QUERY = "/oic/p";
74     public static final int DEFAULT_PRESENCE_TTL = 60;
75     public static final String PRESENCE_URI = "/oic/ad";
76
77     private static volatile boolean sIsPlatformInitialized = false;
78     private static QualityOfService sPlatformQualityOfService = QualityOfService.NA;
79
80     private OcPlatform() {
81     }
82
83     /**
84      * API for setting the configuration of the OcPlatform.
85      * <p>
86      * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
87      * </p>
88      *
89      * @param platformConfig platform configuration
90      */
91     public synchronized static void Configure(PlatformConfig platformConfig) {
92         if (!sIsPlatformInitialized) {
93             CaInterface.initialize(platformConfig.getActivity(), platformConfig.getContext());
94
95             sPlatformQualityOfService = platformConfig.getQualityOfService();
96
97             OcPlatform.configure(
98                     platformConfig.getServiceType().getValue(),
99                     platformConfig.getModeType().getValue(),
100                     platformConfig.getIpAddress(),
101                     platformConfig.getPort(),
102                     platformConfig.getQualityOfService().getValue(),
103                     platformConfig.getSvrDbPath()
104             );
105
106             sIsPlatformInitialized = true;
107         }
108     }
109
110     private static native void configure(int serviceType,
111                                          int modeType,
112                                          String ipAddress,
113                                          int port,
114                                          int qualityOfService,
115                                          String dbPath);
116
117     /**
118      * API for notifying base that resource's attributes have changed.
119      * <p>
120      * Note: This API is for server side only.
121      * </p>
122      *
123      * @param ocResourceHandle resource handle of the resource
124      * @throws OcException if failure
125      */
126     public static void notifyAllObservers(
127             OcResourceHandle ocResourceHandle) throws OcException {
128         OcPlatform.initCheck();
129         OcPlatform.notifyAllObservers0(ocResourceHandle);
130     }
131
132     private static native void notifyAllObservers0(
133             OcResourceHandle ocResourceHandle) throws OcException;
134
135     /**
136      * API for notifying base that resource's attributes have changed.
137      * <p>
138      * Note: This API is for server side only.
139      * </p>
140      *
141      * @param ocResourceHandle resource handle of the resource
142      * @param qualityOfService the quality of communication
143      * @throws OcException if failure
144      */
145     public static void notifyAllObservers(
146             OcResourceHandle ocResourceHandle,
147             QualityOfService qualityOfService) throws OcException {
148         OcPlatform.initCheck();
149         OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
150     }
151
152     private static native void notifyAllObservers1(
153             OcResourceHandle ocResourceHandle,
154             int qualityOfService) throws OcException;
155
156     /**
157      * API for notifying only specific clients that resource's attributes have changed.
158      * <p>
159      * Note: This API is for server side only.
160      * </p>
161      *
162      * @param ocResourceHandle    resource handle of the resource
163      * @param ocObservationIdList These set of ids are ones which which will be notified upon
164      *                            resource change.
165      * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
166      *                            this resource change
167      * @throws OcException if failure
168      */
169     public static void notifyListOfObservers(
170             OcResourceHandle ocResourceHandle,
171             List<Byte> ocObservationIdList,
172             OcResourceResponse ocResourceResponse) throws OcException {
173         OcPlatform.initCheck();
174
175         byte[] idArr = new byte[ocObservationIdList.size()];
176         Iterator<Byte> it = ocObservationIdList.iterator();
177         int i = 0;
178         while (it.hasNext()) {
179             idArr[i++] = (byte) it.next();
180         }
181
182         OcPlatform.notifyListOfObservers2(
183                 ocResourceHandle,
184                 idArr,
185                 ocResourceResponse);
186     }
187
188     private static native void notifyListOfObservers2(
189             OcResourceHandle ocResourceHandle,
190             byte[] ocObservationIdArray,
191             OcResourceResponse ocResourceResponse) throws OcException;
192
193     /**
194      * API for notifying only specific clients that resource's attributes have changed.
195      * <p>
196      * Note: This API is for server side only.
197      * </p>
198      *
199      * @param ocResourceHandle    resource handle of the resource
200      * @param ocObservationIdList These set of ids are ones which which will be notified upon
201      *                            resource change.
202      * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
203      *                            this resource change
204      * @param qualityOfService    the quality of communication
205      * @throws OcException if failure
206      */
207     public static void notifyListOfObservers(
208             OcResourceHandle ocResourceHandle,
209             List<Byte> ocObservationIdList,
210             OcResourceResponse ocResourceResponse,
211             QualityOfService qualityOfService) throws OcException {
212         OcPlatform.initCheck();
213
214         byte[] idArr = new byte[ocObservationIdList.size()];
215         Iterator<Byte> it = ocObservationIdList.iterator();
216         int i = 0;
217         while (it.hasNext()) {
218             idArr[i++] = (byte) it.next();
219         }
220
221         OcPlatform.notifyListOfObservers3(
222                 ocResourceHandle,
223                 idArr,
224                 ocResourceResponse,
225                 qualityOfService.getValue()
226         );
227     }
228
229     private static native void notifyListOfObservers3(
230             OcResourceHandle ocResourceHandle,
231             byte[] ocObservationIdArray,
232             OcResourceResponse ocResourceResponse,
233             int qualityOfService) throws OcException;
234
235     /**
236      * API for Service and Resource Discovery
237      * <p>
238      * Note: This API is for client side only.
239      * </p>
240      *
241      * @param host                    Host Address of a service to direct resource discovery query.
242      *                                If empty, performs multicast resource discovery query
243      * @param resourceUri             name of the resource. If null or empty, performs search for all
244      *                                resource names
245      * @param connectivityTypeSet     Set of types of connectivity. Example: IP
246      * @param onResourceFoundListener Handles events, success states and failure states.
247      * @throws OcException if failure
248      */
249     public static void findResource(
250             String host,
251             String resourceUri,
252             EnumSet<OcConnectivityType> connectivityTypeSet,
253             OnResourceFoundListener onResourceFoundListener) throws OcException {
254         OcPlatform.initCheck();
255
256         int connTypeInt = 0;
257
258         for (OcConnectivityType connType : OcConnectivityType.values()) {
259             if (connectivityTypeSet.contains(connType))
260                 connTypeInt |= connType.getValue();
261         }
262
263         OcPlatform.findResource0(
264                 host,
265                 resourceUri,
266                 connTypeInt,
267                 onResourceFoundListener
268         );
269     }
270
271     private static native void findResource0(
272             String host,
273             String resourceUri,
274             int connectivityType,
275             OnResourceFoundListener onResourceFoundListener) throws OcException;
276
277     /**
278      * API for Service and Resource Discovery.
279      * <p>
280      * Note: This API is for client side only.
281      * </p>
282      *
283      * @param host                    Host IP Address of a service to direct resource discovery query.
284      *                                If empty, performs multicast resource discovery query
285      * @param resourceUri             name of the resource. If null or empty, performs search for all
286      *                                resource names
287      * @param connectivityTypeSet     Set of types of connectivity. Example: IP
288      * @param onResourceFoundListener Handles events, success states and failure states.
289      * @param qualityOfService        the quality of communication
290      * @throws OcException if failure
291      */
292     public static void findResource(
293             String host,
294             String resourceUri,
295             EnumSet<OcConnectivityType> connectivityTypeSet,
296             OnResourceFoundListener onResourceFoundListener,
297             QualityOfService qualityOfService) throws OcException {
298         OcPlatform.initCheck();
299
300         int connTypeInt = 0;
301
302         for (OcConnectivityType connType : OcConnectivityType.values()) {
303             if (connectivityTypeSet.contains(connType))
304                 connTypeInt |= connType.getValue();
305         }
306
307         OcPlatform.findResource1(host,
308                 resourceUri,
309                 connTypeInt,
310                 onResourceFoundListener,
311                 qualityOfService.getValue()
312         );
313     }
314
315     private static native void findResource1(
316             String host,
317             String resourceUri,
318             int connectivityType,
319             OnResourceFoundListener onResourceFoundListener,
320             int qualityOfService) throws OcException;
321
322     /**
323      * API for Device Discovery
324      *
325      * @param host                  Host IP Address. If null or empty, Multicast is performed.
326      * @param deviceUri             Uri containing address to the virtual device
327      * @param connectivityTypeSet   Set of types of connectivity. Example: IP
328      * @param onDeviceFoundListener Handles events, success states and failure states.
329      * @throws OcException if failure
330      */
331     public static void getDeviceInfo(
332             String host,
333             String deviceUri,
334             EnumSet<OcConnectivityType> connectivityTypeSet,
335             OnDeviceFoundListener onDeviceFoundListener) throws OcException {
336         OcPlatform.initCheck();
337         int connTypeInt = 0;
338
339         for (OcConnectivityType connType : OcConnectivityType.values()) {
340             if (connectivityTypeSet.contains(connType))
341                 connTypeInt |= connType.getValue();
342         }
343         OcPlatform.getDeviceInfo0(
344                 host,
345                 deviceUri,
346                 connTypeInt,
347                 onDeviceFoundListener
348         );
349     }
350
351     private static native void getDeviceInfo0(
352             String host,
353             String deviceUri,
354             int connectivityType,
355             OnDeviceFoundListener onDeviceFoundListener) throws OcException;
356
357     /**
358      * API for Device Discovery
359      *
360      * @param host                  Host IP Address. If null or empty, Multicast is performed.
361      * @param deviceUri             Uri containing address to the virtual device
362      * @param connectivityTypeSet   Set of types of connectivity. Example: IP
363      * @param onDeviceFoundListener Handles events, success states and failure states.
364      * @param qualityOfService      the quality of communication
365      * @throws OcException if failure
366      */
367     public static void getDeviceInfo(
368             String host,
369             String deviceUri,
370             EnumSet<OcConnectivityType> connectivityTypeSet,
371             OnDeviceFoundListener onDeviceFoundListener,
372             QualityOfService qualityOfService) throws OcException {
373         OcPlatform.initCheck();
374         int connTypeInt = 0;
375
376         for (OcConnectivityType connType : OcConnectivityType.values()) {
377             if (connectivityTypeSet.contains(connType))
378                 connTypeInt |= connType.getValue();
379         }
380         OcPlatform.getDeviceInfo1(
381                 host,
382                 deviceUri,
383                 connTypeInt,
384                 onDeviceFoundListener,
385                 qualityOfService.getValue()
386         );
387     }
388
389     private static native void getDeviceInfo1(
390             String host,
391             String deviceUri,
392             int connectivityType,
393             OnDeviceFoundListener onDeviceFoundListener,
394             int qualityOfService) throws OcException;
395
396     /**
397      * API for Platform Discovery
398      *
399      * @param host                    Host IP Address. If null or empty, Multicast is performed.
400      * @param platformUri             Uri containing address to the platform
401      * @param connectivityTypeSet     Set of types of connectivity. Example: IP
402      * @param onPlatformFoundListener Handles events, success states and failure states.
403      * @throws OcException if failure
404      */
405
406     public static void getPlatformInfo(
407             String host,
408             String platformUri,
409             EnumSet<OcConnectivityType> connectivityTypeSet,
410             OnPlatformFoundListener onPlatformFoundListener) throws OcException {
411         OcPlatform.initCheck();
412         int connTypeInt = 0;
413
414         for (OcConnectivityType connType : OcConnectivityType.values()) {
415             if (connectivityTypeSet.contains(connType))
416                 connTypeInt |= connType.getValue();
417         }
418         OcPlatform.getPlatformInfo0(
419                 host,
420                 platformUri,
421                 connTypeInt,
422                 onPlatformFoundListener
423         );
424     }
425
426     private static native void getPlatformInfo0(
427             String host,
428             String platformUri,
429             int connectivityType,
430             OnPlatformFoundListener onPlatformInfoFoundListener) throws OcException;
431
432     /**
433      * API for Platform Discovery
434      *
435      * @param host                    Host IP Address. If null or empty, Multicast is performed.
436      * @param platformUri             Uri containing address to the platform
437      * @param connectivityTypeSet     Set of types of connectivity. Example: IP
438      * @param onPlatformFoundListener Handles events, success states and failure states.
439      * @param qualityOfService        the quality of communication
440      * @throws OcException if failure
441      */
442
443     public static void getPlatformInfo(
444             String host,
445             String platformUri,
446             EnumSet<OcConnectivityType> connectivityTypeSet,
447             OnPlatformFoundListener onPlatformFoundListener,
448             QualityOfService qualityOfService) throws OcException {
449         OcPlatform.initCheck();
450         int connTypeInt = 0;
451
452         for (OcConnectivityType connType : OcConnectivityType.values()) {
453             if (connectivityTypeSet.contains(connType))
454                 connTypeInt |= connType.getValue();
455         }
456         OcPlatform.getPlatformInfo1(
457                 host,
458                 platformUri,
459                 connTypeInt,
460                 onPlatformFoundListener,
461                 qualityOfService.getValue()
462         );
463     }
464
465     private static native void getPlatformInfo1(
466             String host,
467             String platformUri,
468             int connectivityType,
469             OnPlatformFoundListener onPlatformFoundListener,
470             int qualityOfService) throws OcException;
471
472     /**
473      * This API registers a resource with the server
474      * <p/>
475      * Note: This API applies to server & client side.
476      * </P>
477      *
478      * @param ocResource The instance of OcResource with all data filled
479      * @return resource handle
480      * @throws OcException if failure
481      */
482     public static OcResourceHandle registerResource(
483             OcResource ocResource) throws OcException {
484         OcPlatform.initCheck();
485         return OcPlatform.registerResource0(ocResource);
486     }
487
488     private static native OcResourceHandle registerResource0(
489             OcResource ocResource) throws OcException;
490
491     /**
492      * This API registers a resource with the server NOTE: This API applies to server side only.
493      * <p/>
494      * Note: This API applies to server side only.
495      * </P>
496      *
497      * @param resourceUri         The URI of the resource. Example: "a/light"
498      * @param resourceTypeName    The resource type. Example: "light"
499      * @param resourceInterface   The resource interface (whether it is collection etc).
500      * @param entityHandler       entity handler.
501      * @param resourcePropertySet indicates the property of the resource
502      * @return resource handle
503      * @throws OcException if failure
504      */
505     public static OcResourceHandle registerResource(
506             String resourceUri,
507             String resourceTypeName,
508             String resourceInterface,
509             EntityHandler entityHandler,
510             EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
511         OcPlatform.initCheck();
512
513         int resProperty = 0;
514
515         for (ResourceProperty prop : ResourceProperty.values()) {
516             if (resourcePropertySet.contains(prop))
517                 resProperty |= prop.getValue();
518         }
519
520         return OcPlatform.registerResource1(resourceUri,
521                 resourceTypeName,
522                 resourceInterface,
523                 entityHandler,
524                 resProperty);
525     }
526
527     private static native OcResourceHandle registerResource1(
528             String resourceUri,
529             String resourceTypeName,
530             String resourceInterface,
531             EntityHandler entityHandler,
532             int resourceProperty) throws OcException;
533
534     /**
535      * Register Device Info
536      *
537      * @param ocDeviceInfo object containing all the device specific information
538      * @throws OcException if failure
539      */
540     public static void registerDeviceInfo(
541             OcDeviceInfo ocDeviceInfo) throws OcException {
542         OcPlatform.initCheck();
543         OcPlatform.registerDeviceInfo0(
544                 ocDeviceInfo.getDeviceName(),
545                 ocDeviceInfo.getDeviceTypes().toArray(
546                         new String[ocDeviceInfo.getDeviceTypes().size()]
547                 )
548         );
549     }
550
551     private static native void registerDeviceInfo0(
552             String deviceName,
553             String[] deviceTypes
554     ) throws OcException;
555
556     /**
557      * Register Platform Info
558      *
559      * @param ocPlatformInfo object containing all the platform specific information
560      * @throws OcException if failure
561      */
562     public static void registerPlatformInfo(
563             OcPlatformInfo ocPlatformInfo) throws OcException {
564         OcPlatform.initCheck();
565         OcPlatform.registerPlatformInfo0(
566                 ocPlatformInfo.getPlatformId(),
567                 ocPlatformInfo.getManufacturerName(),
568                 ocPlatformInfo.getManufacturerUrl(),
569                 ocPlatformInfo.getModelNumber(),
570                 ocPlatformInfo.getDateOfManufacture(),
571                 ocPlatformInfo.getPlatformVersion(),
572                 ocPlatformInfo.getOperatingSystemVersion(),
573                 ocPlatformInfo.getHardwareVersion(),
574                 ocPlatformInfo.getFirmwareVersion(),
575                 ocPlatformInfo.getSupportUrl(),
576                 ocPlatformInfo.getSystemTime()
577         );
578     }
579
580     private static native void registerPlatformInfo0(
581             String platformId, String manufacturerName, String manufacturerUrl,
582             String modelNumber, String dateOfManufacture, String platformVersion,
583             String operatingSystemVersion, String hardwareVersion, String firmwareVersion,
584             String supportUrl, String systemTime
585     ) throws OcException;
586
587     /**
588      * This API unregisters a resource with the server NOTE: This API applies to server side only.
589      *
590      * @param ocResourceHandle This is the resource handle which we which to unregister from the
591      *                         server
592      * @throws OcException if failure
593      */
594     public static void unregisterResource(
595             OcResourceHandle ocResourceHandle) throws OcException {
596         OcPlatform.initCheck();
597         OcPlatform.unregisterResource0(ocResourceHandle);
598     }
599
600     private static native void unregisterResource0(
601             OcResourceHandle ocResourceHandle) throws OcException;
602
603
604     /**
605      * Add a resource to a collection resource
606      *
607      * @param ocResourceCollectionHandle handle to the collection resource
608      * @param ocResourceHandle           handle to resource to be added to the collection resource
609      * @throws OcException if failure
610      */
611     public static void bindResource(
612             OcResourceHandle ocResourceCollectionHandle,
613             OcResourceHandle ocResourceHandle) throws OcException {
614         OcPlatform.initCheck();
615         OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
616     }
617
618     private static native void bindResource0(
619             OcResourceHandle ocResourceCollectionHandle,
620             OcResourceHandle ocResourceHandle) throws OcException;
621
622     /**
623      * Add multiple resources to a collection resource.
624      *
625      * @param ocResourceCollectionHandle handle to the collection resource
626      * @param ocResourceHandleList       reference to list of resource handles to be added to the
627      *                                   collection resource
628      * @throws OcException if failure
629      */
630     public static void bindResources(
631             OcResourceHandle ocResourceCollectionHandle,
632             List<OcResourceHandle> ocResourceHandleList) throws OcException {
633         OcPlatform.initCheck();
634         OcPlatform.bindResources0(
635                 ocResourceCollectionHandle,
636                 ocResourceHandleList.toArray(
637                         new OcResourceHandle[ocResourceHandleList.size()])
638         );
639     }
640
641     private static native void bindResources0(
642             OcResourceHandle ocResourceCollectionHandle,
643             OcResourceHandle[] ocResourceHandleArray) throws OcException;
644
645     /**
646      * Unbind a resource from a collection resource.
647      *
648      * @param ocResourceCollectionHandle handle to the collection resource
649      * @param ocResourceHandle           resource handle to be unbound from the collection resource
650      * @throws OcException if failure
651      */
652     public static void unbindResource(
653             OcResourceHandle ocResourceCollectionHandle,
654             OcResourceHandle ocResourceHandle) throws OcException {
655         OcPlatform.initCheck();
656         OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
657     }
658
659     private static native void unbindResource0(
660             OcResourceHandle ocResourceCollectionHandle,
661             OcResourceHandle ocResourceHandle) throws OcException;
662
663     /**
664      * Unbind resources from a collection resource.
665      *
666      * @param ocResourceCollectionHandle Handle to the collection resource
667      * @param ocResourceHandleList       List of resource handles to be unbound from the collection
668      *                                   resource
669      * @throws OcException if failure
670      */
671     public static void unbindResources(
672             OcResourceHandle ocResourceCollectionHandle,
673             List<OcResourceHandle> ocResourceHandleList) throws OcException {
674         OcPlatform.initCheck();
675         OcPlatform.unbindResources0(
676                 ocResourceCollectionHandle,
677                 ocResourceHandleList.toArray(
678                         new OcResourceHandle[ocResourceHandleList.size()])
679         );
680     }
681
682     private static native void unbindResources0(
683             OcResourceHandle ocResourceCollectionHandle,
684             OcResourceHandle[] ocResourceHandleArray) throws OcException;
685
686     /**
687      * Binds a type to a particular resource
688      *
689      * @param ocResourceHandle handle to the resource
690      * @param resourceTypeName new typename to bind to the resource
691      * @throws OcException if failure
692      */
693     public static void bindTypeToResource(
694             OcResourceHandle ocResourceHandle,
695             String resourceTypeName) throws OcException {
696         OcPlatform.initCheck();
697         OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
698     }
699
700     private static native void bindTypeToResource0(
701             OcResourceHandle ocResourceHandle,
702             String resourceTypeName) throws OcException;
703
704     /**
705      * Binds an interface to a particular resource
706      *
707      * @param ocResourceHandle      handle to the resource
708      * @param resourceInterfaceName new interface to bind to the resource
709      * @throws OcException if failure
710      */
711     public static void bindInterfaceToResource(
712             OcResourceHandle ocResourceHandle,
713             String resourceInterfaceName) throws OcException {
714         OcPlatform.initCheck();
715         OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
716     }
717
718     private static native void bindInterfaceToResource0(
719             OcResourceHandle ocResourceHandle,
720             String resourceInterfaceName) throws OcException;
721
722     /**
723      * Start Presence announcements.
724      *
725      * @param ttl time to live in seconds
726      * @throws OcException if failure
727      */
728     public static void startPresence(int ttl) throws OcException {
729         OcPlatform.initCheck();
730         OcPlatform.startPresence0(ttl);
731     }
732
733     private static native void startPresence0(int ttl) throws OcException;
734
735     /**
736      * Stop Presence announcements.
737      *
738      * @throws OcException if failure
739      */
740     public static void stopPresence() throws OcException {
741         OcPlatform.initCheck();
742         OcPlatform.stopPresence0();
743     }
744
745     private static native void stopPresence0() throws OcException;
746
747     /**
748      * Subscribes to a server's presence change events. By making this subscription, every time a
749      * server adds/removes/alters a resource, starts or is intentionally stopped
750      *
751      * @param host                The IP address/addressable name of the server to subscribe to
752      * @param connectivityTypeSet Set of types of connectivity. Example: IP
753      * @param onPresenceListener  listener that will receive notifications/subscription events
754      * @return a handle object that can be used to identify this subscription request. It can be
755      * used to unsubscribe from these events in the future
756      * @throws OcException if failure
757      */
758     public static OcPresenceHandle subscribePresence(
759             String host,
760             EnumSet<OcConnectivityType> connectivityTypeSet,
761             OnPresenceListener onPresenceListener) throws OcException {
762         OcPlatform.initCheck();
763         int connTypeInt = 0;
764
765         for (OcConnectivityType connType : OcConnectivityType.values()) {
766             if (connectivityTypeSet.contains(connType))
767                 connTypeInt |= connType.getValue();
768         }
769         return OcPlatform.subscribePresence0(
770                 host,
771                 connTypeInt,
772                 onPresenceListener
773         );
774     }
775
776     private static native OcPresenceHandle subscribePresence0(
777             String host,
778             int connectivityType,
779             OnPresenceListener onPresenceListener) throws OcException;
780
781     /**
782      * Subscribes to a server's presence change events. By making this subscription, every time a
783      * server adds/removes/alters a resource, starts or is intentionally stopped
784      *
785      * @param host                The IP address/addressable name of the server to subscribe to
786      * @param resourceType        a resource type specified as a filter for subscription events.
787      * @param connectivityTypeSet Set of types of connectivity. Example: IP
788      * @param onPresenceListener  listener that will receive notifications/subscription events
789      * @return a handle object that can be used to identify this subscription request. It can be
790      * used to unsubscribe from these events in the future
791      * @throws OcException if failure
792      */
793     public static OcPresenceHandle subscribePresence(
794             String host,
795             String resourceType,
796             EnumSet<OcConnectivityType> connectivityTypeSet,
797             OnPresenceListener onPresenceListener) throws OcException {
798         OcPlatform.initCheck();
799         int connTypeInt = 0;
800
801         for (OcConnectivityType connType : OcConnectivityType.values()) {
802             if (connectivityTypeSet.contains(connType))
803                 connTypeInt |= connType.getValue();
804         }
805         return OcPlatform.subscribePresence1(
806                 host,
807                 resourceType,
808                 connTypeInt,
809                 onPresenceListener);
810     }
811
812     private static native OcPresenceHandle subscribePresence1(
813             String host,
814             String resourceType,
815             int connectivityType,
816             OnPresenceListener onPresenceListener) throws OcException;
817
818     /**
819      * Unsubscribes from a previously subscribed server's presence events. Note that you may for
820      * a short time still receive events from the server since it may take time for the
821      * unsubscribe to take effect.
822      *
823      * @param ocPresenceHandle the handle object provided by the subscribePresence call that
824      *                         identifies this subscription
825      * @throws OcException if failure
826      */
827     public static void unsubscribePresence(
828             OcPresenceHandle ocPresenceHandle) throws OcException {
829         OcPlatform.initCheck();
830         OcPlatform.unsubscribePresence0(ocPresenceHandle);
831     }
832
833     private static native void unsubscribePresence0(
834             OcPresenceHandle ocPresenceHandle) throws OcException;
835
836     /**
837      * Subscribes to a server's device presence change events.
838      *
839      * @param host                The IP address/addressable name of the server to subscribe to.
840      * @param di                  Vector which can have the devices id.
841      * @param connectivityTypeSet Set of connectivity types, e.g. IP.
842      * @param onObserveListener   The handler method will be invoked with a map
843      *                            of attribute name and values.
844      * @return a handle object that can be used to identify this subscription request.
845      *         It can be used to unsubscribe from these events in the future.
846      * @throws OcException if failure.
847      */
848     public static OcPresenceHandle subscribeDevicePresence(
849             String host,
850             List<String> di,
851             EnumSet<OcConnectivityType> connectivityTypeSet,
852             OcResource.OnObserveListener onObserveListener) throws OcException {
853         OcPlatform.initCheck();
854         int connTypeInt = 0;
855
856         for (OcConnectivityType connType : OcConnectivityType.values()) {
857             if (connectivityTypeSet.contains(connType))
858                 connTypeInt |= connType.getValue();
859         }
860         return OcPlatform.subscribeDevicePresence0(
861                 host,
862                 di.toArray(new String[di.size()]),
863                 connTypeInt,
864                 onObserveListener);
865     }
866
867     private static native OcPresenceHandle subscribeDevicePresence0(
868             String host,
869             String[] di,
870             int connectivityType,
871             OcResource.OnObserveListener onObserveListener) throws OcException;
872
873     /**
874      * Creates a resource proxy object so that get/put/observe functionality can be used without
875      * discovering the object in advance. Note that the consumer of this method needs to provide
876      * all of the details required to correctly contact and observe the object. If the consumer
877      * lacks any of this information, they should discover the resource object normally.
878      * Additionally, you can only create this object if OcPlatform was initialized to be a Client
879      * or Client/Server.
880      *
881      * @param host                a string containing a resolvable host address of the server holding
882      *                            the resource
883      * @param uri                 the rest of the resource's URI that will permit messages to be
884      *                            properly routed.
885      *                            Example: /a/light
886      * @param connectivityTypeSet Set of types of connectivity. Example: IP
887      * @param isObservable        a boolean containing whether the resource supports observation
888      * @param resourceTypeList    a collection of resource types implemented by the resource
889      * @param interfaceList       a collection of interfaces that the resource supports/implements
890      * @return new resource object
891      * @throws OcException if failure
892      */
893     public static OcResource constructResourceObject(
894             String host,
895             String uri,
896             EnumSet<OcConnectivityType> connectivityTypeSet,
897             boolean isObservable,
898             List<String> resourceTypeList,
899             List<String> interfaceList) throws OcException {
900         OcPlatform.initCheck();
901         int connTypeInt = 0;
902
903         for (OcConnectivityType connType : OcConnectivityType.values()) {
904             if (connectivityTypeSet.contains(connType))
905                 connTypeInt |= connType.getValue();
906         }
907         return OcPlatform.constructResourceObject0(
908                 host,
909                 uri,
910                 connTypeInt,
911                 isObservable,
912                 resourceTypeList.toArray(new String[resourceTypeList.size()]),
913                 interfaceList.toArray(new String[interfaceList.size()])
914         );
915     }
916
917     private static native OcResource constructResourceObject0(
918             String host,
919             String uri,
920             int connectivityType,
921             boolean isObservable,
922             String[] resourceTypes,
923             String[] interfaces) throws OcException;
924
925     /**
926      * Allows application entity handler to send response to an incoming request.
927      *
928      * @param ocResourceResponse resource response
929      * @throws OcException if failure
930      */
931     public static void sendResponse(OcResourceResponse ocResourceResponse)
932             throws OcException {
933         OcPlatform.initCheck();
934         OcPlatform.sendResponse0(ocResourceResponse);
935     }
936
937     private static native void sendResponse0(OcResourceResponse ocResourceResponse)
938             throws OcException;
939
940     /**
941      *  Method to find all devices which are eligible for direct pairing and return the list.
942      *
943      *  @param timeout timeout for discovering direct pair devices.
944      *  @param FindDirectPairingListener Callback function, which will receive the list of direct
945      *                                  pairable devices.
946      *  @throws OcException
947      */
948    public static native void findDirectPairingDevices(int timeout,
949             FindDirectPairingListener onFindDirectPairingListener) throws OcException;
950
951     /**
952      *  Method to get list of all paired devices for a given device.
953      *
954      *  @param GetDirectPairedListener Callback function, which will receive the list of direct
955      *                                 paired devices.
956      *  @throws OcException
957      */
958     public native void getDirectPairedDevices(GetDirectPairedListener onGetDirectPairedListener)
959         throws OcException;
960
961     /**
962      *  Method to perform direct pairing between two devices.
963      *
964      *  @param peer  Target peer
965      *  @param prmType Pairing Method to be used for Pairing
966      *  @param pin pin
967      *  @param DirectPairingListener Callback function, which will be called after
968      *                                      completion of direct pairing.
969      *  @throws OcException
970      */
971     public static void doDirectPairing(
972             OcDirectPairDevice peer,
973             OcPrmType prmType,
974             String pin,
975             DirectPairingListener onDirectPairingListener) throws OcException {
976
977         OcPlatform.doDirectPairing0(
978                 peer,
979                 prmType.getValue(),
980                 pin,
981                 onDirectPairingListener
982                 );
983     }
984
985     private static native void doDirectPairing0(OcDirectPairDevice peer,
986             int pmSel, String pinNumber, DirectPairingListener onDirectPairingListener)
987     throws OcException;
988
989     /**
990      * API to publish resource to remote resource-directory.
991      *
992      * @param host                        Host Address of a service to publish resource.
993      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
994      * @param onPublishResourceListener   Handles events, success states and failure states.
995      * @throws OcException if failure
996      */
997     public static void publishResourceToRD(
998             String host,
999             EnumSet<OcConnectivityType> connectivityTypeSet,
1000             OnPublishResourceListener onPublishResourceListener) throws OcException {
1001         OcPlatform.initCheck();
1002
1003         int connTypeInt = 0;
1004
1005         for (OcConnectivityType connType : OcConnectivityType.values()) {
1006             if (connectivityTypeSet.contains(connType)) {
1007                 connTypeInt |= connType.getValue();
1008             }
1009         }
1010
1011         OcPlatform.publishResourceToRD0(
1012                 host,
1013                 connTypeInt,
1014                 onPublishResourceListener,
1015                 sPlatformQualityOfService.getValue()
1016         );
1017     }
1018
1019     /**
1020      * API to publish resource to remote resource-directory.
1021      *
1022      * @param host                        Host Address of a service to publish resource.
1023      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1024      * @param onPublishResourceListener   Handles events, success states and failure states.
1025      * @param qualityOfService            the quality of communication.
1026      * @throws OcException if failure
1027      */
1028     public static void publishResourceToRD(
1029             String host,
1030             EnumSet<OcConnectivityType> connectivityTypeSet,
1031             OnPublishResourceListener onPublishResourceListener,
1032             QualityOfService qualityOfService) throws OcException {
1033         OcPlatform.initCheck();
1034
1035         int connTypeInt = 0;
1036
1037         for (OcConnectivityType connType : OcConnectivityType.values()) {
1038             if (connectivityTypeSet.contains(connType)) {
1039                 connTypeInt |= connType.getValue();
1040             }
1041         }
1042
1043         OcPlatform.publishResourceToRD0(
1044                 host,
1045                 connTypeInt,
1046                 onPublishResourceListener,
1047                 qualityOfService.getValue()
1048         );
1049     }
1050
1051     private static native void publishResourceToRD0(
1052             String host,
1053             int connectivityType,
1054             OnPublishResourceListener onPublishResourceListener,
1055             int qualityOfService) throws OcException;
1056
1057     /**
1058      * API to publish resource to remote resource-directory.
1059      *
1060      * @param host                        Host Address of a service to publish resource.
1061      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1062      * @param ocResourceHandleList        reference to list of resource handles to be published.
1063      * @param onPublishResourceListener   Handles events, success states and failure states.
1064      * @throws OcException if failure
1065      */
1066     public static void publishResourceToRD(
1067             String host,
1068             EnumSet<OcConnectivityType> connectivityTypeSet,
1069             List<OcResourceHandle> ocResourceHandleList,
1070             OnPublishResourceListener onPublishResourceListener) throws OcException {
1071         OcPlatform.initCheck();
1072
1073         int connTypeInt = 0;
1074
1075         for (OcConnectivityType connType : OcConnectivityType.values()) {
1076             if (connectivityTypeSet.contains(connType)) {
1077                 connTypeInt |= connType.getValue();
1078             }
1079         }
1080
1081         OcPlatform.publishResourceToRD1(
1082                 host,
1083                 connTypeInt,
1084                 ocResourceHandleList.toArray(
1085                         new OcResourceHandle[ocResourceHandleList.size()]),
1086                 onPublishResourceListener,
1087                 sPlatformQualityOfService.getValue()
1088         );
1089     }
1090
1091     /**
1092      * API to publish resource to remote resource-directory.
1093      *
1094      * @param host                        Host IP Address of a service to publish resource.
1095      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1096      * @param ocResourceHandleList        reference to list of resource handles to be published.
1097      * @param onPublishResourceListener   Handles events, success states and failure states.
1098      * @param qualityOfService            the quality of communication
1099      * @throws OcException if failure
1100      */
1101     public static void publishResourceToRD(
1102             String host,
1103             EnumSet<OcConnectivityType> connectivityTypeSet,
1104             List<OcResourceHandle> ocResourceHandleList,
1105             OnPublishResourceListener onPublishResourceListener,
1106             QualityOfService qualityOfService) throws OcException {
1107         OcPlatform.initCheck();
1108
1109         int connTypeInt = 0;
1110
1111         for (OcConnectivityType connType : OcConnectivityType.values()) {
1112             if (connectivityTypeSet.contains(connType)) {
1113                 connTypeInt |= connType.getValue();
1114             }
1115         }
1116
1117         OcPlatform.publishResourceToRD1(
1118             host,
1119             connTypeInt,
1120             ocResourceHandleList.toArray(
1121                     new OcResourceHandle[ocResourceHandleList.size()]),
1122             onPublishResourceListener,
1123             qualityOfService.getValue()
1124         );
1125     }
1126
1127     private static native void publishResourceToRD1(
1128             String host,
1129             int connectivityType,
1130             OcResourceHandle[] ocResourceHandleArray,
1131             OnPublishResourceListener onPublishResourceListener,
1132             int qualityOfService) throws OcException;
1133
1134     /**
1135      * API to delete resource from remote resource-directory.
1136      *
1137      * @param host                        Host Address of a service to publish resource.
1138      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1139      * @param onDeleteResourceListener    Handles events, success states and failure states.
1140      * @throws OcException if failure
1141      */
1142     public static void deleteResourceFromRD(
1143             String host,
1144             EnumSet<OcConnectivityType> connectivityTypeSet,
1145             OnDeleteResourceListener onDeleteResourceListener) throws OcException {
1146         OcPlatform.initCheck();
1147
1148         int connTypeInt = 0;
1149
1150         for (OcConnectivityType connType : OcConnectivityType.values()) {
1151             if (connectivityTypeSet.contains(connType)) {
1152                 connTypeInt |= connType.getValue();
1153             }
1154         }
1155
1156         OcPlatform.deleteResourceFromRD0(
1157                 host,
1158                 connTypeInt,
1159                 onDeleteResourceListener,
1160                 sPlatformQualityOfService.getValue()
1161         );
1162     }
1163
1164     /**
1165      * API to delete resource from remote resource-directory.
1166      *
1167      * @param host                        Host Address of a service to publish resource.
1168      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1169      * @param onDeleteResourceListener    Handles events, success states and failure states.
1170      * @param qualityOfService            the quality of communication.
1171      * @throws OcException if failure
1172      */
1173     public static void deleteResourceFromRD(
1174             String host,
1175             EnumSet<OcConnectivityType> connectivityTypeSet,
1176             OnDeleteResourceListener onDeleteResourceListener,
1177             QualityOfService qualityOfService) throws OcException {
1178         OcPlatform.initCheck();
1179
1180         int connTypeInt = 0;
1181
1182         for (OcConnectivityType connType : OcConnectivityType.values()) {
1183             if (connectivityTypeSet.contains(connType)) {
1184                 connTypeInt |= connType.getValue();
1185             }
1186         }
1187
1188         OcPlatform.deleteResourceFromRD0(
1189                 host,
1190                 connTypeInt,
1191                 onDeleteResourceListener,
1192                 qualityOfService.getValue()
1193         );
1194     }
1195
1196     private static native void deleteResourceFromRD0(
1197             String host,
1198             int connectivityType,
1199             OnDeleteResourceListener onDeleteResourceListener,
1200             int qualityOfService) throws OcException;
1201
1202     /**
1203      * API to delete resource from remote resource-directory.
1204      *
1205      * @param host                        Host Address of a service to publish resource.
1206      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1207      * @param ocResourceHandleList        reference to list of resource handles to be published.
1208      * @param onDeleteResourceListener          Handles events, success states and failure states.
1209      * @throws OcException if failure
1210      */
1211     public static void deleteResourceFromRD(
1212             String host,
1213             EnumSet<OcConnectivityType> connectivityTypeSet,
1214             List<OcResourceHandle> ocResourceHandleList,
1215             OnDeleteResourceListener onDeleteResourceListener) throws OcException {
1216         OcPlatform.initCheck();
1217
1218         int connTypeInt = 0;
1219
1220         for (OcConnectivityType connType : OcConnectivityType.values()) {
1221             if (connectivityTypeSet.contains(connType)) {
1222                 connTypeInt |= connType.getValue();
1223             }
1224         }
1225
1226         OcPlatform.deleteResourceFromRD1(
1227                 host,
1228                 connTypeInt,
1229                 ocResourceHandleList.toArray(
1230                         new OcResourceHandle[ocResourceHandleList.size()]),
1231                 onDeleteResourceListener,
1232                 sPlatformQualityOfService.getValue()
1233         );
1234     }
1235
1236     /**
1237      * API to delete resource from remote resource-directory.
1238      *
1239      * @param host                        Host IP Address of a service to publish resource.
1240      * @param connectivityTypeSet         Set of types of connectivity. Example: IP
1241      * @param ocResourceHandleList        reference to list of resource handles to be published.
1242      * @param onDeleteResourceListener    Handles events, success states and failure states.
1243      * @param qualityOfService            the quality of communication
1244      * @throws OcException if failure
1245      */
1246     public static void deleteResourceFromRD(
1247             String host,
1248             EnumSet<OcConnectivityType> connectivityTypeSet,
1249             List<OcResourceHandle> ocResourceHandleList,
1250             OnDeleteResourceListener onDeleteResourceListener,
1251             QualityOfService qualityOfService) throws OcException {
1252         OcPlatform.initCheck();
1253
1254         int connTypeInt = 0;
1255
1256         for (OcConnectivityType connType : OcConnectivityType.values()) {
1257             if (connectivityTypeSet.contains(connType)) {
1258                 connTypeInt |= connType.getValue();
1259             }
1260         }
1261
1262         OcPlatform.deleteResourceFromRD1(
1263             host,
1264             connTypeInt,
1265             ocResourceHandleList.toArray(
1266                     new OcResourceHandle[ocResourceHandleList.size()]),
1267             onDeleteResourceListener,
1268             qualityOfService.getValue()
1269         );
1270     }
1271
1272     private static native void deleteResourceFromRD1(
1273             String host,
1274             int connectivityType,
1275             OcResourceHandle[] ocResourceHandleArray,
1276             OnDeleteResourceListener onDeleteResourceListener,
1277             int qualityOfService) throws OcException;
1278
1279     /**
1280      * An OnPublishResourceListener can be registered via the OcPlatform.publishResourceToRD call.
1281      * Event listeners are notified asynchronously
1282      */
1283     public interface OnPublishResourceListener {
1284         public void onPublishResourceCompleted(OcRepresentation ocRepresentation);
1285         public void onPublishResourceFailed(Throwable ex);
1286     }
1287
1288     /**
1289      * An OnDeleteResourceListener can be registered via the OcPlatform.deleteResourceFromRD call.
1290      * Event listeners are notified asynchronously
1291      */
1292     public interface OnDeleteResourceListener {
1293         public void onDeleteResourceCompleted(int result);
1294     }
1295
1296     /**
1297      * An FindDirectPairingListener can be registered via the OcPlatform.findDirectPairingDevices call.
1298      * Event listeners are notified asynchronously
1299      */
1300     public interface FindDirectPairingListener {
1301         public void onFindDirectPairingListener(List<OcDirectPairDevice> ocPairedDeviceList);
1302     }
1303
1304     /**
1305      * Listerner to Get List of already Direct Paired devices.
1306      * An GetDirectPairedListener can be registered via the OcPlatform.getDirectPairedDevices call.
1307      * Event listeners are notified asynchronously
1308      */
1309     public interface GetDirectPairedListener {
1310         public void onGetDirectPairedListener(List<OcDirectPairDevice> ocPairedDeviceList);
1311     }
1312
1313     /**
1314      * Listner to get result of doDirectPairing.
1315      * An DirectPairingListener can be registered via the OcPlatform.doDirectPairing call.
1316      * Event listeners are notified asynchronously
1317      */
1318     public interface DirectPairingListener {
1319         public void onDirectPairingListener(String devId, int result);
1320     }
1321
1322     /**
1323      * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
1324      * Event listeners are notified asynchronously
1325      */
1326     public interface OnResourceFoundListener {
1327         public void onResourceFound(OcResource resource);
1328         public void onFindResourceFailed(Throwable ex, String uri);
1329     }
1330
1331     /**
1332      * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
1333      * Event listeners are notified asynchronously
1334      */
1335     public interface OnDeviceFoundListener {
1336         public void onDeviceFound(OcRepresentation ocRepresentation);
1337     }
1338
1339     /**
1340      * An OnPlatformFoundListener can be registered via the OcPlatform.getPlatformInfo call.
1341      * Event listeners are notified asynchronously
1342      */
1343     public interface OnPlatformFoundListener {
1344         public void onPlatformFound(OcRepresentation ocRepresentation);
1345     }
1346
1347     /**
1348      * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
1349      * Event listeners are notified asynchronously
1350      */
1351     public interface OnPresenceListener {
1352         public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
1353     }
1354
1355     /**
1356      * An EntityHandler can be registered via the OcPlatform.registerResource call.
1357      * Event listeners are notified asynchronously
1358      *
1359      * @note entityhandler callback :
1360      * When you set specific return value like EntityHandlerResult.OK, SLOW
1361      * and etc in entity handler callback,
1362      * ocstack will be not send response automatically to client
1363      * except for error return value like EntityHandlerResult.ERROR
1364      * If you want to send response to client with specific result,
1365      * sendResponse API should be called with the result value.
1366      */
1367     public interface EntityHandler {
1368         public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
1369     }
1370
1371     private static void initCheck() {
1372         if (!sIsPlatformInitialized) {
1373             throw new IllegalStateException("OcPlatform must be configured by making a call to " +
1374                     "OcPlatform.Configure before any other API calls are permitted");
1375         }
1376     }
1377
1378     /**
1379      * Gets platform quality of service
1380      *
1381      * @return quality of service
1382      */
1383     public static QualityOfService getPlatformQualityOfService() {
1384         OcPlatform.initCheck();
1385         return sPlatformQualityOfService;
1386     }
1387
1388     /**
1389      * Create an account manager object that can be used for doing request to account server.
1390      * You can only create this object if OCPlatform was initialized to be a Client or
1391      * Client/Server. Otherwise, this will return an empty shared ptr.
1392      *
1393      * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
1394      *       methods of this object to work since device id is not generated on Client mode.
1395      *
1396      * @param host                Host IP Address of a account server.
1397      * @param connectivityTypeSet Set of types of connectivity. Example: CT_ADAPTER_IP
1398      * @return new AccountManager object
1399      * @throws OcException if failure
1400      */
1401     public static OcAccountManager constructAccountManagerObject(
1402             String host,
1403             EnumSet<OcConnectivityType> connectivityTypeSet) throws OcException {
1404         OcPlatform.initCheck();
1405         int connTypeInt = 0;
1406
1407         for (OcConnectivityType connType : OcConnectivityType.values()) {
1408             if (connectivityTypeSet.contains(connType))
1409             {
1410                 connTypeInt |= connType.getValue();
1411             }
1412         }
1413         return OcPlatform.constructAccountManagerObject0(
1414                 host,
1415                 connTypeInt
1416                 );
1417     }
1418
1419     private static native OcAccountManager constructAccountManagerObject0(
1420             String host,
1421             int connectivityType) throws OcException;
1422 }