Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / PlatformConfig.java
index 4ffacd4..487f6a9 100644 (file)
 package org.iotivity.base;
 
 import android.content.Context;
+import android.app.Activity;
 
 /**
  * Data structure to provide the configuration.
  */
 public class PlatformConfig {
-
+    private Activity mActivity;
     private Context mContext;
     private ServiceType mServiceType;
     private ModeType mModeType;
@@ -37,8 +38,8 @@ public class PlatformConfig {
     private QualityOfService mQualityOfService;
     private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage.
                               //this is only for 0.9.2
-
     /**
+     * @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
@@ -51,13 +52,15 @@ public class PlatformConfig {
      * @param qualityOfService quality of service
      * @param dbPath           Persistant storage file for SVR Database.
      */
-    public PlatformConfig(Context context,
+    public PlatformConfig(Activity activity,
+                          Context context,
                           ServiceType serviceType,
                           ModeType modeType,
                           String ipAddress,
                           int port,
                           QualityOfService qualityOfService,
                           String dbPath) {
+        this.mActivity=activity;
         this.mContext = context;
         this.mServiceType = serviceType;
         this.mModeType = modeType;
@@ -78,17 +81,63 @@ 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.
+     */
+    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.
+    // 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, "");
+        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;
     }
@@ -116,4 +165,9 @@ public class PlatformConfig {
     public String getSvrDbPath() {
         return mSvrDbPath;
     }
+
+    public Activity getActivity() {
+        return mActivity;
+    }
+
 }