Adding more samsung specific properties
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / PlatformConfig.java
1 /*
2  *******************************************************************
3  *
4  * Copyright 2015 Intel Corporation.
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 android.content.Context;
26 import android.app.Activity;
27 import java.util.EnumSet;
28 /**
29  * Data structure to provide the configuration.
30  */
31 public class PlatformConfig {
32     private Activity mActivity;
33     private Context mContext;
34     private ServiceType mServiceType;
35     private ModeType mModeType;
36     private String mIpAddress;
37     private int mPort;
38     private QualityOfService mQualityOfService;
39     private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage.
40                               //this is only for 0.9.2
41     private String mSvrDbPathDefault;
42     private String mSvrDbPathRescue;
43     private int mKeySize;
44     private byte[] mKey;
45     private int mTransportType;
46     private byte[] mUuidSeed;
47     private int mUuidSeedSize;
48
49     /**
50      * @param activity         app activity
51      * @param context          app context
52      * @param serviceType      indicate IN_PROC or OUT_OF_PROC
53      * @param modeType         indicate whether we want to do server, client or both
54      * @param ipAddress        ip address of server
55      *                         if you specify 0.0.0.0 : it listens on any interface
56      * @param port             port of server
57      *                         if you specifiy 0 : next available random port is used
58      *                         if you specify 5683 : client discovery can work even if they don't
59      *                         specify port
60      * @param qualityOfService quality of service
61      * @param dbPath           Persistant storage file for SVR Database.
62      * @param uuidSeed         byte array of seed value for gernerating UUID.
63      * @param uuidSeedSize     length of seed
64      */
65     public PlatformConfig(Activity activity,
66                           Context context,
67                           ServiceType serviceType,
68                           ModeType modeType,
69                           String ipAddress,
70                           int port,
71                           QualityOfService qualityOfService,
72                           String dbPath,
73                           byte[] seed,
74                           int seedSize) {
75         this.mActivity=activity;
76         this.mContext = context;
77         this.mServiceType = serviceType;
78         this.mModeType = modeType;
79         this.mIpAddress = ipAddress;
80         this.mPort = port;
81         this.mQualityOfService = qualityOfService;
82         this.mSvrDbPath = dbPath;
83         this.mTransportType = 0;
84         this.mUuidSeed = seed;
85         this.mUuidSeedSize = seedSize;
86     }
87
88     public PlatformConfig(Context context,
89                           ServiceType serviceType,
90                           ModeType modeType,
91                           String ipAddress,
92                           int port,
93                           QualityOfService qualityOfService,
94                           String dbPath,
95                           String dbPathDefault,
96                           String dbPathRescue,
97                           int keySize,
98                           byte[] key) {
99         this.mContext = context;
100         this.mServiceType = serviceType;
101         this.mModeType = modeType;
102         this.mIpAddress = ipAddress;
103         this.mPort = port;
104         this.mQualityOfService = qualityOfService;
105         this.mSvrDbPath = dbPath;
106         this.mSvrDbPathDefault = dbPathDefault;
107         this.mSvrDbPathRescue = dbPathRescue;
108         this.mKeySize = keySize;
109         this.mKey = key;
110         this.mTransportType = 0;
111     }
112
113     /**
114      * @param context          app context
115      * @param serviceType      indicate IN_PROC or OUT_OF_PROC
116      * @param modeType         indicate whether we want to do server, client or both
117      * @param ipAddress        ip address of server
118      *                         if you specify 0.0.0.0 : it listens on any interface
119      * @param port             port of server
120      *                         if you specifiy 0 : next available random port is used
121      *                         if you specify 5683 : client discovery can work even if they don't
122      *                         specify port
123      * @param qualityOfService quality of service
124      * @param dbPath           Persistant storage file for SVR Database.
125      */
126     public PlatformConfig(Context context,
127                           ServiceType serviceType,
128                           ModeType modeType,
129                           String ipAddress,
130                           int port,
131                           QualityOfService qualityOfService,
132                           String dbPath) {
133         this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, dbPath, null, 0);
134     }
135
136     /**
137      * @param context          app context
138      * @param serviceType      indicate IN_PROC or OUT_OF_PROC
139      * @param modeType         indicate whether we want to do server, client or both
140      * @param ipAddress        ip address of server
141      *                         if you specify 0.0.0.0 : it listens on any interface
142      * @param port             port of server
143      *                         if you specifiy 0 : next available random port is used
144      *                         if you specify 5683 : client discovery can work even if they don't
145      *                         specify port
146      * @param qualityOfService quality of service
147      * @param dbPath           Persistant storage file for SVR Database.
148      * @param uuidSeed         byte array of seed value for gernerating UUID.
149      * @param uuidSeedSize     length of seed
150      */
151     public PlatformConfig(Context context,
152                           ServiceType serviceType,
153                           ModeType modeType,
154                           String ipAddress,
155                           int port,
156                           QualityOfService qualityOfService,
157                           String dbPath,
158                           byte[] uuidSeed,
159                           int uuidSeedSize) {
160         this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, dbPath, uuidSeed, uuidSeedSize);
161     }
162
163     /**
164      * @param context          app context
165      * @param serviceType      indicate IN_PROC or OUT_OF_PROC
166      * @param modeType         indicate whether we want to do server, client or both
167      * @param ipAddress        ip address of server
168      *                         if you specify 0.0.0.0 : it listens on any interface
169      * @param port             port of server
170      *                         if you specifiy 0 : next available random port is used
171      *                         if you specify 5683 : client discovery can work even if they don't
172      *                         specify port
173      * @param qualityOfService quality of service
174      */
175     // Avoid breaking building java samples due to persistent storage SVR DB changes.
176     public PlatformConfig(Context context,
177                           ServiceType serviceType,
178                           ModeType modeType,
179                           String ipAddress,
180                           int port,
181                           QualityOfService qualityOfService) {
182         this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, "", null, 0);
183     }
184
185     /**
186      * @param activity         app activity
187      * @param context          app context
188      * @param serviceType      indicate IN_PROC or OUT_OF_PROC
189      * @param modeType         indicate whether we want to do server, client or both
190      * @param ipAddress        ip address of server
191      *                         if you specify 0.0.0.0 : it listens on any interface
192      * @param port             port of server
193      *                         if you specifiy 0 : next available random port is used
194      *                         if you specify 5683 : client discovery can work even if they don't
195      *                         specify port
196      * @param qualityOfService quality of service
197      */
198     // Avoid breaking building java samples due to persistent storage SVR DB changes.
199     public PlatformConfig(Activity activity,
200                           Context context,
201                           ServiceType serviceType,
202                           ModeType modeType,
203                           String ipAddress,
204                           int port,
205                           QualityOfService qualityOfService) {
206         this(activity,context,serviceType,modeType,ipAddress,port,qualityOfService, "", null, 0);
207     }
208     public Context getContext() {
209         return mContext;
210     }
211
212     public ServiceType getServiceType() {
213         return mServiceType;
214     }
215
216     public ModeType getModeType() {
217         return mModeType;
218     }
219
220     public String getIpAddress() {
221         return mIpAddress;
222     }
223
224     public int getPort() {
225         return mPort;
226     }
227
228     public QualityOfService getQualityOfService() {
229         return mQualityOfService;
230     }
231
232     public String getSvrDbPath() {
233         return mSvrDbPath;
234     }
235
236     public Activity getActivity() {
237         return mActivity;
238     }
239
240     public String getDBDefaultPath() {
241         return mSvrDbPathDefault;
242     }
243
244     public String getDBRescuePath() {
245         return mSvrDbPathRescue;
246     }
247
248     public int getKeySize()
249     {
250         return mKeySize;
251     }
252
253     public byte[] getKey()
254     {
255         return mKey;
256     }
257
258     public void setAvailableTransportType(EnumSet<OcConnectivityType> type) {
259         for (OcConnectivityType connType : OcConnectivityType.values()) {
260             if (type.contains(connType))
261                 mTransportType |= connType.getValue();
262         }
263     }
264
265     public int getAvailableTransportType() {
266         return mTransportType;
267     }
268
269     public byte[] getUuidSeed()
270     {
271         return mUuidSeed;
272     }
273
274     public int getUuidSeedSize()
275     {
276         return mUuidSeedSize;
277     }
278 }