bootstrap: add feature to change port number(50051-50060). 58/309258/4
authorHosang Kim <hosang12.kim@samsung.com>
Mon, 8 Apr 2024 04:57:53 +0000 (13:57 +0900)
committerkim hosang <hosang12.kim@samsung.com>
Mon, 15 Apr 2024 05:37:32 +0000 (05:37 +0000)
ex)
tv
app_launcher -s org.tizen.aurum-bootstrap port 50051

fhub
app_launcher -s org.tizen.aurum-bootstrap port 50052

Change-Id: I4b4fef76d8815192a06a54fcb1dc0307515797a4

org.tizen.aurum-bootstrap/src/BootstrapServer.cc

index 7ae8188b084a31d2b94aa3fce1e17d857bdf9130..5acc8ee20e4698df26dc84d2829c0220f5ed192d 100644 (file)
@@ -20,6 +20,7 @@
 #include <glib.h>
 #include <vconf.h>
 #include <system_info.h>
+#include <bundle_internal.h>
 
 #include "AurumServiceImpl.h"
 #include "config.h"
@@ -30,6 +31,7 @@ typedef struct _ServiceContext {
     GThread *thread;
     std::unique_ptr<Server> server;
     bool forceTouchEnabled;
+    int port;
 } ServiceContext;
 
 static void _vconf_force_enable_touch_set(void *data, bool enable)
@@ -52,7 +54,8 @@ static gpointer
 _grpc_thread_func(gpointer data)
 {
     ServiceContext *ctx = (ServiceContext *)data;
-    std::string binding("0.0.0.0:50051");
+    std::string binding("0.0.0.0:");
+    binding.append(std::to_string(ctx->port));
     aurumServiceImpl service;
     ServerBuilder builder;
     char *value;
@@ -123,6 +126,21 @@ int main(int argc, char **argv)
 
     int result = -1;
 
+    bundle *b  = bundle_import_from_argv(argc, argv);
+    char *port = NULL;
+    bundle_get_str (b, "port",  &port);
+    if (!port) {
+        ctx.port = 50051;
+    }
+    else {
+        ctx.port = atoi(port);
+        if (ctx.port < 50051 || ctx.port > 50061) {
+            LOGE("Port number is invalid!");
+            ctx.port = 50051;
+        }
+    }
+    bundle_free(b);
+
     try {
        result = service_app_main(argc, argv, &event_callback, &ctx);
     } catch (const std::exception& e) {