Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcDirectPairDevice.java
1 /*
2  * //******************************************************************
3  * //
4  * // Copyright 2016 Samsung Electronics All Rights Reserved.
5  * //
6  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7  * //
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  * //
12  * //      http://www.apache.org/licenses/LICENSE-2.0
13  * //
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  * //
20  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21  */
22
23 package org.iotivity.base;
24
25 import java.util.List;
26 import java.util.EnumSet;
27 import java.util.Map;
28 import java.util.Arrays;
29 import java.util.ArrayList;
30
31 public class OcDirectPairDevice {
32
33
34     private long mNativeHandle;
35     private String mdeviceID;
36     private String mHost;
37
38     private OcDirectPairDevice(long nativeHandle) {
39         this.mNativeHandle = nativeHandle;
40     }
41
42     public OcDirectPairDevice(String deviceID)
43     {
44         this.mdeviceID = deviceID;
45     }
46
47     public String getDevId()
48     {
49         return this.mdeviceID;
50     }
51
52     public native String getHost();
53
54     public List<Integer> getPairingMethodList() {
55         int [] intList = this.getPairingMethods();
56         List<Integer> prmList = new ArrayList<Integer>();
57         for (int i = 0; i < intList.length; i++)
58         {
59             prmList.add(intList[i]);
60         }
61         return  prmList;
62     }
63
64     private native int[] getPairingMethods();
65
66     /**
67      * Method to get the connectivity type of this resource
68      *
69      * @return EnumSet<OcConnectivityType></OcConnectivityType> connectivity type set
70      */
71     public EnumSet<OcConnectivityType> getConnectivityTypeSet() {
72         return OcConnectivityType.convertToEnumSet(
73                 this.getConnectivityTypeN()
74         );
75     }
76
77     private native int getConnectivityTypeN();
78
79
80     /**
81      *  Method to get list of all paired devices for a given device.
82      *
83      *  @param GetDirectPairedListener Callback function, which will receive the list of direct paired devices.
84      *  @throws OcException
85      */
86
87     public native void getDirectPairedDevices(GetDirectPairedListener getDirectPairedListener) throws OcException;
88
89     public interface GetDirectPairedListener {
90         public void getDirectPairedListener(List<String> ocPairedDeviceList);
91     }
92
93     /**
94      *  Method to perform direct pairing between two devices.
95      *
96      *  @param DirectPairingListener Callback function, which will be called after
97      *                                      completion of direct pairing.
98      *  @throws OcException
99      */
100     public native void doDirectPairing(OcDirectPairDevice peer,
101             OcPrmType pmSel, String pinNumber,
102             DirectPairingListener directPairingListener) throws OcException;
103
104
105     public interface DirectPairingListener {
106         public void directPairingListener(String devId, int result);
107     }
108
109     @Override
110     public String toString() {
111         return this.mdeviceID;
112     }
113 }