void Launchpad::HandlePingRequest(std::shared_ptr<Request> request) {
request->SendResult(getpid());
+ ping_received_ = true;
+ for (auto& iter : fast_launches_) {
+ pid_t pid = iter.first;
+ auto& appid = iter.second;
+ tizen_base::Bundle b = {
+ { kAulAppId, appid },
+ { kAulPid, std::to_string(pid) }
+ };
+
+ Util::SendCmdToAmd(AmdCmd::AppRegisterPid, b.GetHandle(),
+ static_cast<int>(AmdSocketOption::NoReply | AmdSocketOption::Bundle));
+ }
+ fast_launches_.clear();
_W("[PAD_CMD_PING]");
}
pid_map_[request->GetPid()] = app_info->GetAppId();
launchpad::Log::Print("[LAUNCH]", "pid(%7d) | appid(%s)",
request->GetPid(), app_info->GetAppId().c_str());
+ if (app_info->IsFastLaunch()) {
+ if (ping_received_) {
+ tizen_base::Bundle b = {
+ { kAulAppId, app_info->GetAppId() },
+ { kAulPid, std::to_string(request->GetPid()) }
+ };
+
+ Util::SendCmdToAmd(AmdCmd::AppRegisterPid, b.GetHandle(),
+ static_cast<int>(
+ AmdSocketOption::NoReply | AmdSocketOption::Bundle));
+ } else {
+ fast_launches_[request->GetPid()] = app_info->GetAppId();
+ }
+ }
}
}
}
void Launchpad::OnSigchldReceived(pid_t pid) {
+ fast_launches_.erase(pid);
auto found = pid_map_.find(pid);
if (found != pid_map_.end()) {
auto appid = found->second;
std::unique_ptr<Worker> cleaner_;
std::vector<std::shared_ptr<Request>> pending_requests_;
Config::LaunchMode::Mode mode_;
+ bool ping_received_ = false;
+ std::unordered_map<pid_t, std::string> fast_launches_;
};
} // namespace launchpad
};
enum AmdCmd {
+ AppRegisterPid = 57,
LaunchpadDeadSignal = 61,
LaunchpadLaunchSignal = 83,
AppStartupSignal = 89,
};
+enum class AmdSocketOption : int {
+ None = 0x0,
+ NoReply = 0x1,
+ Async = 0x2,
+ Queue = 0x4,
+ Bundle = 0x8
+};
+
} // namespace launchpad
#endif // LIB_LAUNCHPAD_COMMON_TYPES_HH_
return *this;
}
+AppInfo::Builder& AppInfo::Builder::SetFastLaunch(const tizen_base::Bundle& b) {
+ if (b.GetString(kAulFastLaunch) == "true")
+ fast_launch_ = true;
+ else
+ fast_launch_ = false;
+
+ return *this;
+}
+
AppInfo::Builder& AppInfo::Builder::SetGlobal(const tizen_base::Bundle& b) {
if (b.GetString(kAulIsGlobal) == "true")
global_ = true;
std::move(original_app_path_), std::move(pkg_type_), std::move(app_type_),
std::move(hwacc_), std::move(taskmanage_), std::move(pkg_id_),
std::move(comp_type_), std::move(internal_pool_), std::move(root_path_),
- std::move(loader_name_), global_, std::move(b_));
+ std::move(loader_name_), fast_launch_, global_, std::move(b_));
}
AppInfo* AppInfo::Create(tizen_base::Bundle b) {
.SetInternalPool(b)
.SetRootPath(b)
.SetLoaderName(b)
+ .SetFastLaunch(b)
.SetGlobal(b)
.SetBundle(std::move(b));
}
return loader_name_;
}
+const bool AppInfo::IsFastLaunch() const {
+ return fast_launch_;
+}
+
const bool AppInfo::IsGlobal() const {
return global_;
}
parcel->WriteString(internal_pool_);
parcel->WriteString(root_path_);
parcel->WriteString(loader_name_);
+ parcel->WriteBool(fast_launch_);
parcel->WriteBool(global_);
bundle_raw* b_raw = nullptr;
internal_pool_ = parcel->ReadString();
root_path_ = parcel->ReadString();
loader_name_ = parcel->ReadString();
+ parcel->ReadBool(&fast_launch_);
parcel->ReadBool(&global_);
auto raw = parcel->ReadString();
std::string original_app_path, std::string pkg_type, std::string app_type,
std::string hwacc, std::string taskmanage, std::string pkg_id,
std::string comp_type, std::string internal_pool, std::string root_path,
- std::string loader_name, bool global, tizen_base::Bundle b)
+ std::string loader_name, bool fast_launch, bool global,
+ tizen_base::Bundle b)
: app_id_(std::move(app_id)),
app_path_(std::move(app_path)),
original_app_path_(std::move(original_app_path)),
internal_pool_(std::move(internal_pool)),
root_path_(std::move(root_path)),
loader_name_(std::move(loader_name)),
+ fast_launch_(fast_launch),
global_(global),
b_(std::move(b)) {}
Builder& SetInternalPool(const tizen_base::Bundle& b);
Builder& SetRootPath(const tizen_base::Bundle& b);
Builder& SetLoaderName(const tizen_base::Bundle& b);
+ Builder& SetFastLaunch(const tizen_base::Bundle& b);
Builder& SetGlobal(const tizen_base::Bundle& b);
Builder& SetBundle(tizen_base::Bundle b);
operator AppInfo*();
std::string internal_pool_;
std::string root_path_;
std::string loader_name_;
- bool global_;
+ bool fast_launch_ = false;
+ bool global_ = true;
tizen_base::Bundle b_;
};
const std::string& GetInternalPool() const;
const std::string& GetRootPath() const;
const std::string& GetLoaderName() const;
+ const bool IsFastLaunch() const;
const bool IsGlobal() const;
const tizen_base::Bundle& GetBundle() const;
std::string original_app_path, std::string pkg_type, std::string app_type,
std::string hwacc, std::string taskmanage, std::string pkg_id,
std::string comp_type, std::string internal_pool, std::string root_path,
- std::string loader_name, bool global, tizen_base::Bundle b);
+ std::string loader_name, bool fast_launch, bool global,
+ tizen_base::Bundle b);
private:
std::string app_id_;
std::string internal_pool_;
std::string root_path_;
std::string loader_name_;
+ bool fast_launch_ = false;
bool global_ = true;
tizen_base::Bundle b_;
};
#include "launchpad-glib/util.hh"
+#include <bundle_internal.h>
#include <dbus/dbus.h>
#include <stdlib.h>
#include <sys/mount.h>
class AmdPacket : public tizen_base::Parcelable {
public:
- explicit AmdPacket(int cmd) : cmd_(cmd) {}
+ explicit AmdPacket(int cmd, bundle* request, int opt)
+ : cmd_(cmd), request_(request), opt_(opt) {}
void WriteToParcel(tizen_base::Parcel* parcel) const {
parcel->WriteInt32(cmd_);
- parcel->WriteInt32(0);
- parcel->WriteInt32(0);
+ if (request_ == nullptr) {
+ parcel->WriteInt32(0);
+ parcel->WriteInt32(opt_);
+ } else {
+ bundle_raw* raw = nullptr;
+ int len = 0;
+ bundle_encode(request_, &raw, &len);
+ parcel->WriteInt32(len);
+ parcel->WriteInt32(opt_);
+ parcel->Write(reinterpret_cast<unsigned char*>(raw), len);
+ bundle_free_encoded_rawdata(&raw);
+ }
}
void ReadFromParcel(tizen_base::Parcel* parcel) {
}
private:
- int cmd_;
+ int cmd_ = -1;
+ bundle* request_ = nullptr;
+ int opt_ = 0;
};
} // namespace
}
int Util::SendCmdToAmd(enum AmdCmd cmd) {
+ return SendCmdToAmd(cmd, nullptr, static_cast<int>(AmdSocketOption::None));
+}
+
+int Util::SendCmdToAmd(enum AmdCmd cmd, bundle* request, int opt) {
try {
std::string endpoint = "/run/aul/daemons/.amd-sock";
ClientSocket socket;
socket.SetReceiveBufferSize(Socket::kSocketMaxBufferSize);
socket.SetReceiveTimeout(5000);
- AmdPacket packet(static_cast<int>(cmd));
+ AmdPacket packet(static_cast<int>(cmd), request, opt);
tizen_base::Parcel parcel;
parcel.WriteParcelable(packet);
#ifndef LIB_LAUNCHPAD_GLIB_UTIL_HH_
#define LIB_LAUNCHPAD_GLIB_UTIL_HH_
+#include <bundle.h>
#include <sys/types.h>
#include <tzplatform_config.h>
static int PrepareAppSocket();
static int PrepareAppIdFile(const AppInfo* app_info);
static int SendCmdToAmd(enum AmdCmd cmd);
+ static int SendCmdToAmd(enum AmdCmd cmd, bundle* request, int opt);
};
} // namespace launchpad