Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / service / easy-setup / sdk / mediator / android / EasySetupCore / src / main / java / org / iotivity / service / easysetup / mediator / EnrolleeDeviceFactory.java
1 /**
2  * ***************************************************************
3  * <p/>
4  * Copyright 2015 Samsung Electronics All Rights Reserved.
5  * <p/>
6  * <p/>
7  * <p/>
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  * <p/>
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * <p/>
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  * <p/>
20  * ****************************************************************
21  */
22
23 package org.iotivity.service.easysetup.mediator;
24
25 import android.content.Context;
26
27 /**
28  * This a factory class provides the native implementation of the various Enrollee devices.
29  * Application can make use of Enrollee factory if it does not want to create its own Enrollee devices.
30  */
31 public class EnrolleeDeviceFactory {
32
33     Context mContext;
34
35     /**
36      * This method create & returns instance of EnrolleeDeviceFactory
37      *
38      * @param context This is Android Application context
39      */
40     public static EnrolleeDeviceFactory newInstance(Context context) {
41         return new EnrolleeDeviceFactory(context);
42     }
43
44     private EnrolleeDeviceFactory(Context context) {
45         mContext = context;
46     }
47
48     /**
49      * This method create & returns instance of Enrollee device of supported configuration
50      *
51      * @param onboardingConfig Contains details about the connectivity to be established between the Enrollee device & Mediator device in order to perform on-boarding
52      * @param provConfig       Contains details about the network to which Enrollee device is going to connect.
53      * @return Instance of the Enrollee device created natively.
54      */
55
56     public EnrolleeDevice newEnrolleeDevice(OnBoardingConfig onboardingConfig, ProvisioningConfig provConfig) {
57
58         if (onboardingConfig.getConnType() != OnBoardingConfig.ConnType.WiFi) {
59             throw new IllegalArgumentException("OnBoarding configuration is not supported");
60         }
61
62         EnrolleeDevice enrolleeDevice;
63         enrolleeDevice = new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
64
65         return enrolleeDevice;
66     }
67
68 }