2 * ***************************************************************
4 * Copyright 2017 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.mediator;
25 import android.content.Context;
26 import android.util.Log;
28 import java.io.IOException;
29 import java.util.ArrayList;
32 * This is facade class, a single point of contact for Application.
33 * It contains set of APIs to do easy setup of the enrolling device.
34 * ON-BOARDING - This is a step to establish connectivity between the device & Mediator device.
35 * PROVISION - This is a step where the netowork's detail & credentials are given to the
38 public class EasySetup {
40 private static final String TAG = EasySetup.class.getName();
42 private static EasySetup sInstance;
44 //private final EasySetupStatus mCallback;
46 //private ArrayList<EnrolleeDevice> mEnrolleeDeviceList;
48 //private final ProvisioningCallback mProvisioningCallback;
50 private static Context mContext;
52 private ArrayList<RemoteEnrollee> mRemoteEnrolleeList;
54 protected RemoteEnrollee mRemoteEnrollee;
56 //function to call the native createEnrolleeDevice
57 private native RemoteEnrollee nativeCreateRemoteEnrollee();
60 // Load Easy Setup JNI interface
61 System.loadLibrary("ESMediatorRich");
62 System.loadLibrary("easysetup-jni");
66 //mCallback = callback;
67 //mProvisioningCallback = new ProvisioningCallbackImpl(mCallback);
68 //mEnrolleeDeviceList = new ArrayList<EnrolleeDevice>();
73 * Gives a singleton instance of Easy setup service and initialize the service
75 * @param callback Application needs to provide this callback to receive the status of easy
79 public synchronized static EasySetup getInstance(Context context) {
80 if (sInstance == null) {
81 sInstance = new EasySetup();
87 public synchronized RemoteEnrollee createRemoteEnrollee()
90 mRemoteEnrollee = nativeCreateRemoteEnrollee();
92 mRemoteEnrolleeList.add(mRemoteEnrollee);
94 return mRemoteEnrollee;
98 * Reset the Easy setup Service
101 public void finish() {
102 //Call the stop Provisioning
103 //for (EnrolleeDevice enrolleeDevice : mEnrolleeDeviceList) {
104 // enrolleeDevice.stopProvisioningProcess();