X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=android%2Fandroid_api%2Fbase%2Fsrc%2Fmain%2Fjava%2Forg%2Fiotivity%2Fbase%2FPlatformConfig.java;h=e02602c0c3101ae9c66e76cccf0877279c16138c;hb=refs%2Ftags%2Ftizen_4.0.m2_release;hp=70d9df38073429ce7b26f50f64a633723ae23f45;hpb=4cdd52ff8df4763bd414732f5f845de04ef2dfe6;p=platform%2Fupstream%2Fiotivity.git diff --git a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java index 70d9df3..e02602c 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java @@ -1,72 +1,105 @@ -/* - * //****************************************************************** - * // - * // Copyright 2015 Intel Corporation. - * // - * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - * // - * // Licensed under the Apache License, Version 2.0 (the "License"); - * // you may not use this file except in compliance with the License. - * // You may obtain a copy of the License at - * // - * // http://www.apache.org/licenses/LICENSE-2.0 - * // - * // Unless required by applicable law or agreed to in writing, software - * // distributed under the License is distributed on an "AS IS" BASIS, - * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * // See the License for the specific language governing permissions and - * // limitations under the License. - * // - * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - */ - -package org.iotivity.base; - -import android.content.Context; - -/** - * Data structure to provide the configuration. - */ -public class PlatformConfig { - - private Context mContext; - private ServiceType mServiceType; - private ModeType mModeType; - private String mIpAddress; - private int mPort; - private QualityOfService mQualityOfService; +/* + ******************************************************************* + * + * Copyright 2015 Intel Corporation. + * + *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + */ + +package org.iotivity.base; + +import android.content.Context; +import android.app.Activity; +import java.util.EnumSet; +/** + * Data structure to provide the configuration. + */ +public class PlatformConfig { + private Activity mActivity; + private Context mContext; + private ServiceType mServiceType; + private ModeType mModeType; + private String mIpAddress; + private int mPort; + private QualityOfService mQualityOfService; private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage. //this is only for 0.9.2 - - /** - * @param context app context - * @param serviceType indicate IN_PROC or OUT_OF_PROC - * @param modeType indicate whether we want to do server, client or both - * @param ipAddress ip address of server - * if you specify 0.0.0.0 : it listens on any interface - * @param port port of server - * if you specifiy 0 : next available random port is used - * if you specify 5683 : client discovery can work even if they don't - * specify port - * @param qualityOfService quality of service + private String mSvrDbPathDefault; + private String mSvrDbPathRescue; + private int mKeySize; + private byte[] mKey; + private int mTransportType; + /** + * @param activity app activity + * @param context app context + * @param serviceType indicate IN_PROC or OUT_OF_PROC + * @param modeType indicate whether we want to do server, client or both + * @param ipAddress ip address of server + * if you specify 0.0.0.0 : it listens on any interface + * @param port port of server + * if you specifiy 0 : next available random port is used + * if you specify 5683 : client discovery can work even if they don't + * specify port + * @param qualityOfService quality of service * @param dbPath Persistant storage file for SVR Database. - */ - public PlatformConfig(Context context, - ServiceType serviceType, - ModeType modeType, - String ipAddress, - int port, + */ + public PlatformConfig(Activity activity, + Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, QualityOfService qualityOfService, String dbPath) { - this.mContext = context; - this.mServiceType = serviceType; - this.mModeType = modeType; - this.mIpAddress = ipAddress; - this.mPort = port; - this.mQualityOfService = qualityOfService; + this.mActivity=activity; + this.mContext = context; + this.mServiceType = serviceType; + this.mModeType = modeType; + this.mIpAddress = ipAddress; + this.mPort = port; + this.mQualityOfService = qualityOfService; this.mSvrDbPath = dbPath; + this.mTransportType = 0; } + public PlatformConfig(Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService, + String dbPath, + String dbPathDefault, + String dbPathRescue, + int keySize, + byte[] key) { + this.mContext = context; + this.mServiceType = serviceType; + this.mModeType = modeType; + this.mIpAddress = ipAddress; + this.mPort = port; + this.mQualityOfService = qualityOfService; + this.mSvrDbPath = dbPath; + this.mSvrDbPathDefault = dbPathDefault; + this.mSvrDbPathRescue = dbPathRescue; + this.mKeySize = keySize; + this.mKey = key; + this.mTransportType = 0; + } /** * @param context app context * @param serviceType indicate IN_PROC or OUT_OF_PROC @@ -78,42 +111,121 @@ public class PlatformConfig { * if you specify 5683 : client discovery can work even if they don't * specify port * @param qualityOfService quality of service + * @param dbPath Persistant storage file for SVR Database. */ - //Avoid breaking building java samples due to persistent storage SVR DB changes. + public PlatformConfig(Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService, + String dbPath) { + this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, dbPath); + } + + /** + * @param context app context + * @param serviceType indicate IN_PROC or OUT_OF_PROC + * @param modeType indicate whether we want to do server, client or both + * @param ipAddress ip address of server + * if you specify 0.0.0.0 : it listens on any interface + * @param port port of server + * if you specifiy 0 : next available random port is used + * if you specify 5683 : client discovery can work even if they don't + * specify port + * @param qualityOfService quality of service + */ + // Avoid breaking building java samples due to persistent storage SVR DB changes. public PlatformConfig(Context context, ServiceType serviceType, ModeType modeType, String ipAddress, int port, QualityOfService qualityOfService) { - this(context,serviceType,modeType,ipAddress,port,qualityOfService, ""); - } - - public Context getContext() { - return mContext; - } - - public ServiceType getServiceType() { - return mServiceType; - } - - public ModeType getModeType() { - return mModeType; - } - - public String getIpAddress() { - return mIpAddress; - } - - public int getPort() { - return mPort; - } - - public QualityOfService getQualityOfService() { - return mQualityOfService; + this(null,context,serviceType,modeType,ipAddress,port,qualityOfService, ""); + } + + /** + * @param activity app activity + * @param context app context + * @param serviceType indicate IN_PROC or OUT_OF_PROC + * @param modeType indicate whether we want to do server, client or both + * @param ipAddress ip address of server + * if you specify 0.0.0.0 : it listens on any interface + * @param port port of server + * if you specifiy 0 : next available random port is used + * if you specify 5683 : client discovery can work even if they don't + * specify port + * @param qualityOfService quality of service + */ + // Avoid breaking building java samples due to persistent storage SVR DB changes. + public PlatformConfig(Activity activity, + Context context, + ServiceType serviceType, + ModeType modeType, + String ipAddress, + int port, + QualityOfService qualityOfService) { + this(activity,context,serviceType,modeType,ipAddress,port,qualityOfService, ""); + } + public Context getContext() { + return mContext; + } + + public ServiceType getServiceType() { + return mServiceType; + } + + public ModeType getModeType() { + return mModeType; + } + + public String getIpAddress() { + return mIpAddress; + } + + public int getPort() { + return mPort; + } + + public QualityOfService getQualityOfService() { + return mQualityOfService; } public String getSvrDbPath() { return mSvrDbPath; - } -} + } + + public Activity getActivity() { + return mActivity; + } + + public String getDBDefaultPath() { + return mSvrDbPathDefault; + } + + public String getDBRescuePath() { + return mSvrDbPathRescue; + } + + public int getKeySize() + { + return mKeySize; + } + + public byte[] getKey() + { + return mKey; + } + + public void setAvailableTransportType(EnumSet type) { + for (OcConnectivityType connType : OcConnectivityType.values()) { + if (type.contains(connType)) + mTransportType |= connType.getValue(); + } + } + + public int getAvailableTransportType() { + return mTransportType; + } +}