Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcProvisioning.java
1 /*
2  * //******************************************************************
3  * //
4  * // Copyright 2015 Samsung Electronics All Rights Reserved.
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 java.util.List;
26 import java.util.Arrays;
27 import java.util.Map;
28
29 /**
30  * OcProvisionig represents functions corresponding to the provisioing of
31  * resources.
32  */
33 public class OcProvisioning {
34
35     /**
36      * Method to Intialize Provisioning Manager.This will load the provisioning
37      * Manager's persistent database.
38      *
39      * @param dbPath     dbPath file path of the sqlite3 db.
40      * @throws OcException
41      */
42     public static native void provisionInit(String dbPath) throws OcException;
43
44     /**
45      * Method to Discover un-owned devices in its subnet.Un-owned devices need
46      * to be owned by calling ownershipTransferCBdata.
47      *
48      * @param timeout     Timeout in sec.Time to listen for responses before
49      *                    returining the Array.
50      * @return            Array of OcSecureResource class objects.
51      * @throws OcException
52      */
53     public  static List<OcSecureResource> discoverUnownedDevices(int timeout) throws OcException {
54         return Arrays.asList(OcProvisioning.discoverUnownedDevices1(timeout));
55     }
56     private static native OcSecureResource[] discoverUnownedDevices1(int timeout) throws OcException;
57
58     /**
59      * Method to Discover owned devices in its subnet.
60      *
61      * @param timeout     Timeout in sec.Time to listen for responses before
62      *                    returining the Array.
63      * @return            Array of OcSecureResource class objects.
64      * @throws OcException
65      */
66     public static List<OcSecureResource> discoverOwnedDevices(int timeout) throws OcException {
67         return Arrays.asList(OcProvisioning.discoverOwnedDevices1(timeout));
68     }
69     private static native OcSecureResource[] discoverOwnedDevices1(int timeout) throws OcException;
70
71     /**
72      *  API for registering Ownership transfer methods for a particular
73      *  transfer Type
74      *
75      * @param type     OxmType ownership transfer type.
76      * @throws OcException
77      */
78     public static void SetownershipTransferCBdata(OxmType type,
79             PinCallbackListener pinCallbackListener) throws OcException
80     {
81         OcProvisioning.ownershipTransferCBdata(type.getValue(), pinCallbackListener);
82     }
83
84     private  static native void ownershipTransferCBdata(int oxmType,  PinCallbackListener pinCallbackListener);
85
86     public static interface PinCallbackListener {
87         public String pinCallbackListener();
88     }
89
90     /**
91      * Server API to set Callback for Displaying stack generated PIN.
92      *
93      * @param DisplayPinListener Pin callback Listener to be registered.
94      * @throws OcException
95      */
96     public static native void setDisplayPinListener(DisplayPinListener displayPinListener)
97         throws OcException;
98
99     public static interface DisplayPinListener {
100         public void displayPinListener(String Pin);
101     }
102
103     /**
104      * Method to get Array of owned and un-owned devices in the current subnet.
105      *
106      * @param timeout    timeout in sec for the API to return.
107      * @retrun           Array of OcSecureResource class objects.
108      *                   be provisioned.
109      * @throws OcException
110      */
111     public static List<OcSecureResource> getDeviceStatusList(int timeout) throws OcException {
112         return Arrays.asList(OcProvisioning.getDeviceStatusList1(timeout));
113     }
114     private static native OcSecureResource[] getDeviceStatusList1(int timeout) throws OcException;
115 }