2 * ***************************************************************
4 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * ****************************************************************
23 package org.iotivity.service.easysetup.impl;
25 import org.iotivity.service.easysetup.core.EnrolleeDevice;
26 import org.iotivity.service.easysetup.core.OnBoardingConfig;
27 import org.iotivity.service.easysetup.core.ProvisioningConfig;
29 import android.content.Context;
32 * This a factory class provides the native implementation of the various Enrollee devices.
33 * Application can make use of Enrollee factory if it does not want to create its own Enrollee devices.
35 public class EnrolleeDeviceFactory {
40 * This method create & returns instance of EnrolleeDeviceFactory
42 * @param context This is Android Application context
44 public static EnrolleeDeviceFactory newInstance(Context context) {
45 return new EnrolleeDeviceFactory(context);
48 private EnrolleeDeviceFactory(Context context) {
53 * This method create & returns instance of Enrollee device of supported configuration
55 * @param onboardingConfig Contains details about the connectivity to be established between the Enrollee device & Mediator device in order to perform on-boarding
56 * @param provConfig Contains details about the network to which Enrollee device is going to connect.
57 * @return Instance of the Enrollee device created natively.
60 public EnrolleeDevice newEnrolleeDevice(OnBoardingConfig onboardingConfig, ProvisioningConfig provConfig) {
62 EnrolleeDevice enrolleeDevice;
64 if (onboardingConfig.getConnType() == OnBoardingConfig.ConnType.WiFi) {
65 enrolleeDevice = new EnrolleeDeviceWiFiOnboarding(mContext, onboardingConfig, provConfig);
67 throw new IllegalArgumentException("OnBoarding configuration is not supported");
70 return enrolleeDevice;