c85b051a5700e68a82c3f2be4a05a4f7eca81549
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / android / EasySetupCore / src / main / java / org / iotivity / service / easysetup / core / EasySetupManager.java
1 /**\r
2  * ***************************************************************\r
3  * <p>\r
4  * Copyright 2015 Samsung Electronics All Rights Reserved.\r
5  * <p>\r
6  * <p>\r
7  * <p>\r
8  * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * you may not use this file except in compliance with the License.\r
10  * You may obtain a copy of the License at\r
11  * <p>\r
12  * http://www.apache.org/licenses/LICENSE-2.0\r
13  * <p>\r
14  * Unless required by applicable law or agreed to in writing, software\r
15  * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * See the License for the specific language governing permissions and\r
18  * limitations under the License.\r
19  * <p>\r
20  * ****************************************************************\r
21  */\r
22 package org.iotivity.service.easysetup.core;\r
23 \r
24 import android.content.Context;\r
25 \r
26 import org.iotivity.ca.CaInterface;\r
27 \r
28 public class EasySetupManager {\r
29     private native void InitEasySetup();\r
30 \r
31     private native void TerminateEasySetup();\r
32 \r
33     // TODO : "OcConnectivityType connectivityType" has to be passed as the\r
34     // second parameter for PerformEasySetup\r
35     // instead of integer\r
36     private native void ProvisionEnrollee(String ipAddress, String netSSID,\r
37                                           String netPWD, int connectivityType);\r
38 \r
39     private native void StopEnrolleeProvisioning(int connectivityType);\r
40 \r
41     public static native void initialize(Context context);\r
42 \r
43     private static EasySetupManager easySetupManagerInterfaceObj = null;\r
44     private Context appContext = null;\r
45 \r
46     static {\r
47         // Load Easy Setup JNI interface\r
48         System.loadLibrary("gnustl_shared");\r
49         System.loadLibrary("octbstack");\r
50         System.loadLibrary("connectivity_abstraction");\r
51         System.loadLibrary("easysetup-jni");\r
52     }\r
53 \r
54     private EasySetupManager() {\r
55 \r
56     }\r
57 \r
58     /**\r
59      * Function for Getting instance of EasySetupManager object.\r
60      *\r
61      * @return EasySetupManager instance.\r
62      *\r
63      */\r
64     public static synchronized EasySetupManager getInstance() {\r
65         if (null == easySetupManagerInterfaceObj) {\r
66             easySetupManagerInterfaceObj = new EasySetupManager();\r
67         }\r
68         return easySetupManagerInterfaceObj;\r
69     }\r
70 \r
71     public void setApplicationContext(Context context) {\r
72         appContext = context;\r
73     }\r
74 \r
75     public void initEasySetup() {\r
76         CaInterface.initialize(appContext);\r
77         InitEasySetup();\r
78     }\r
79 \r
80     public void terminateEasySetup() {\r
81         TerminateEasySetup();\r
82     }\r
83 \r
84     public void provisionEnrollee(String ipAddress, String netSSID,\r
85                                   String netPWD, int connectivityType) {\r
86 \r
87         ProvisionEnrollee(ipAddress, netSSID, netPWD, connectivityType);\r
88     }\r
89 \r
90     public void stopEnrolleeProvisioning(int connectivityType) {\r
91         StopEnrolleeProvisioning(connectivityType);\r
92     }\r
93 \r
94 }\r