+ // retrieve ppid
+ std::ostringstream os;
+ os << pid ;
+ string path = "/proc/" + os.str() + "/stat";
+ std::ifstream ifs(path.c_str());
+ string str;
+ unsigned ppid = 0;
+ if(!ifs.fail() && std::getline(ifs, str))
+ {
+ std::sscanf(str.data(), "%*d %*s %*c %*d %d", &ppid);
+ HMI_INFO("Retrieve ppid %d", ppid);
+ }
+ else
+ {
+ HMI_ERROR("Failed to open /proc/%d/stat", pid);
+ HMI_ERROR("File system may be different");
+ return;
+ }
+ // search pid from surfaceID
+ json_object *response;
+ afb_service_call_sync("afm-main", "runners", nullptr, &response);
+
+ // retrieve appid from pid from application manager
+ string appid = "";
+ if(response == nullptr)
+ {
+ HMI_ERROR("No runners");
+ }
+ else
+ {
+ // check appid then add it to the client
+ HMI_INFO("Runners:%s", json_object_get_string(response));
+ int size = json_object_array_length(response);
+ for(int i = 0; i < size; i++)
+ {
+ json_object *j = json_object_array_get_idx(response, i);
+ const char* id = jh::getStringFromJson(j, "id");
+ int runid = jh::getIntFromJson(j, "runid");
+ if(id && (runid > 0))
+ {
+ if(runid == ppid)
+ {
+ appid = id;
+ break;
+ }
+ }
+ }
+ if(appid == "")
+ {
+ HMI_ERROR("Not found");
+ }
+ }
+ json_object_put(response);
+ auto client = g_app_list.lookUpClient(appid);
+ if(client != nullptr)
+ {
+ client->addSurface(surface_id);
+ this->id_alloc.register_name_id(client->role(), surface_id);
+ }
+ struct TmpClient tmp_cl = {appid, ppid};
+ this->tmp_surface2app[surface_id] = tmp_cl; /* Store for requestSurfaceXDG */