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;
33 * This is facade class, a single point of contact for Application.
34 * It contains set of APIs to do easy setup of the enrolling device.
35 * ON-BOARDING - This is a step to establish connectivity between the device & Mediator device.
36 * PROVISION - This is a step where the netowork's detail & credentials are given to the
39 public class EasySetup {
41 private static final String TAG = EasySetup.class.getName();
43 private static EasySetup sInstance;
45 private static Context mContext;
47 private ArrayList<RemoteEnrollee> mRemoteEnrolleeList;
49 protected RemoteEnrollee mRemoteEnrollee;
51 //function to call the native nativeCreateRemoteEnrollee
52 private native RemoteEnrollee nativeCreateRemoteEnrollee();
55 // Load Easy Setup JNI interface
56 System.loadLibrary("ESMediatorRich");
57 System.loadLibrary("easysetup-jni");
61 mRemoteEnrolleeList = new ArrayList<RemoteEnrollee>();
66 * Gives a singleton instance of Easy setup and initialize the easy setup
68 public synchronized static EasySetup getInstance(Context context) {
69 if (sInstance == null) {
70 sInstance = new EasySetup();
77 * API to create a new RemoteEnrollee instance
79 public synchronized RemoteEnrollee createRemoteEnrollee()
82 mRemoteEnrollee = nativeCreateRemoteEnrollee();
83 mRemoteEnrolleeList.add(mRemoteEnrollee);
84 return mRemoteEnrollee;
88 * Reset the Easy setup
90 public void finish() {
91 //Call the stop Provisioning
92 //for (RemoteEnrollee remoteEnrollee : mRemoteEnrolleeList)
93 // remoteEnrollee.stopProvisioningProcess();