2 *******************************************************************
4 * Copyright 2015 Intel Corporation.
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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.base;
25 import android.content.Context;
26 import android.app.Activity;
27 import java.util.EnumSet;
29 * Data structure to provide the configuration.
31 public class PlatformConfig {
32 private Activity mActivity;
33 private Context mContext;
34 private ServiceType mServiceType;
35 private ModeType mModeType;
36 private String mIpAddress;
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;
45 private int mTransportType;
47 * @param activity app activity
48 * @param context app context
49 * @param serviceType indicate IN_PROC or OUT_OF_PROC
50 * @param modeType indicate whether we want to do server, client or both
51 * @param ipAddress ip address of server
52 * if you specify 0.0.0.0 : it listens on any interface
53 * @param port port of server
54 * if you specifiy 0 : next available random port is used
55 * if you specify 5683 : client discovery can work even if they don't
57 * @param qualityOfService quality of service
58 * @param dbPath Persistant storage file for SVR Database.
60 public PlatformConfig(Activity activity,
62 ServiceType serviceType,
66 QualityOfService qualityOfService,
68 this.mActivity=activity;
69 this.mContext = context;
70 this.mServiceType = serviceType;
71 this.mModeType = modeType;
72 this.mIpAddress = ipAddress;
74 this.mQualityOfService = qualityOfService;
75 this.mSvrDbPath = dbPath;
76 this.mTransportType = 0;
79 public PlatformConfig(Context context,
80 ServiceType serviceType,
84 QualityOfService qualityOfService,
90 this.mContext = context;
91 this.mServiceType = serviceType;
92 this.mModeType = modeType;
93 this.mIpAddress = ipAddress;
95 this.mQualityOfService = qualityOfService;
96 this.mSvrDbPath = dbPath;
97 this.mSvrDbPathDefault = dbPathDefault;
98 this.mSvrDbPathRescue = dbPathRescue;
99 this.mKeySize = keySize;
101 this.mTransportType = 0;
104 * @param context app context
105 * @param serviceType indicate IN_PROC or OUT_OF_PROC
106 * @param modeType indicate whether we want to do server, client or both
107 * @param ipAddress ip address of server
108 * if you specify 0.0.0.0 : it listens on any interface
109 * @param port port of server
110 * if you specifiy 0 : next available random port is used
111 * if you specify 5683 : client discovery can work even if they don't
113 * @param qualityOfService quality of service
114 * @param dbPath Persistant storage file for SVR Database.
116 public PlatformConfig(Context context,
117 ServiceType serviceType,
121 QualityOfService qualityOfService,
123 this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, dbPath);
127 * @param context app context
128 * @param serviceType indicate IN_PROC or OUT_OF_PROC
129 * @param modeType indicate whether we want to do server, client or both
130 * @param ipAddress ip address of server
131 * if you specify 0.0.0.0 : it listens on any interface
132 * @param port port of server
133 * if you specifiy 0 : next available random port is used
134 * if you specify 5683 : client discovery can work even if they don't
136 * @param qualityOfService quality of service
138 // Avoid breaking building java samples due to persistent storage SVR DB changes.
139 public PlatformConfig(Context context,
140 ServiceType serviceType,
144 QualityOfService qualityOfService) {
145 this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, "");
149 * @param activity app activity
150 * @param context app context
151 * @param serviceType indicate IN_PROC or OUT_OF_PROC
152 * @param modeType indicate whether we want to do server, client or both
153 * @param ipAddress ip address of server
154 * if you specify 0.0.0.0 : it listens on any interface
155 * @param port port of server
156 * if you specifiy 0 : next available random port is used
157 * if you specify 5683 : client discovery can work even if they don't
159 * @param qualityOfService quality of service
161 // Avoid breaking building java samples due to persistent storage SVR DB changes.
162 public PlatformConfig(Activity activity,
164 ServiceType serviceType,
168 QualityOfService qualityOfService) {
169 this(activity,context,serviceType,modeType,ipAddress,port,qualityOfService, "");
171 public Context getContext() {
175 public ServiceType getServiceType() {
179 public ModeType getModeType() {
183 public String getIpAddress() {
187 public int getPort() {
191 public QualityOfService getQualityOfService() {
192 return mQualityOfService;
195 public String getSvrDbPath() {
199 public Activity getActivity() {
203 public String getDBDefaultPath() {
204 return mSvrDbPathDefault;
207 public String getDBRescuePath() {
208 return mSvrDbPathRescue;
211 public int getKeySize()
216 public byte[] getKey()
221 public void setAvailableTransportType(EnumSet<OcConnectivityType> type) {
222 for (OcConnectivityType connType : OcConnectivityType.values()) {
223 if (type.contains(connType))
224 mTransportType |= connType.getValue();
228 public int getAvailableTransportType() {
229 return mTransportType;