return false;
}
+bool AppControlManager::CheckAppControl(const std::string& device_id,
+ CapabilityManager* cm, const unsigned char* appcontrol, size_t len) {
+ bool found = false;
+ std::vector<RemoteDevice> dev_list = DBManager::SelectDevices();
+ for (auto& dev : dev_list) {
+ if (device_id == dev.device_id())
+ found = true;
+ }
+
+ if (!found) {
+ LOG(ERROR) << "Invalid device_id : " << device_id;
+ return false;
+ }
+
+ bundle* b = bundle_decode(appcontrol, len);
+ if (!b) {
+ LOG(ERROR) << "Invalid bundle data!";
+ return false;
+ }
+
+ const char* appid_cstr = aul_svc_get_appid(b);
+ if (!appid_cstr) {
+ LOG(ERROR) << "Failed to get appid!";
+ bundle_free(b);
+ return false;
+ }
+
+ std::string appid(appid_cstr);
+ std::vector<Capability> cap_list = cm->GetCapabilities();
+ for (const auto& cap : cap_list) {
+ if (appid == cap.appid()) {
+ LOG(INFO) << "Found appcontrol!";
+ bundle_free(b);
+ return true;
+ }
+ }
+
+ LOG(ERROR) << "Invalid appcontrol!";
+ bundle_free(b);
+ return false;
+}
+
int AppControlManager::AulHandler(aul_type type, bundle* kb, void* data) {
return 0;
}
void* data);
bool CheckRemoteAppControl(const std::string& device_id,
const unsigned char* appcontrol, size_t len);
+ bool CheckAppControl(const std::string& device_id, CapabilityManager* cm,
+ const unsigned char* appcontrol, size_t len);
private:
class AppControlReplyHandler {
return true;
}
-std::vector<RemoteDevice> DBManager::SelectDevice() {
+std::vector<RemoteDevice> DBManager::SelectDevices() {
auto guard = Instance().sql_conn_->GetTransactionGuard();
std::shared_ptr<SQLStatement> stmt = Instance().sql_conn_->PrepareStatement(
kQuerySelectDev);
}
std::vector<RemoteDevice> dev_list;
- while (stmt && stmt->Step() == SQLStatement::StepResult::ROW) {
+ while (stmt->Step() == SQLStatement::StepResult::ROW) {
int idx = 0;
std::string device_id = stmt->GetColumnString(idx++);
std::string model_name = stmt->GetColumnString(idx++);
public:
static bool InsertDevice(const RemoteDevice& device);
static bool DeleteDevice(const RemoteDevice& device);
- static std::vector<RemoteDevice> SelectDevice();
+ static std::vector<RemoteDevice> SelectDevices();
static bool InsertCapability(const std::string& device_id,
const Capability& cap);
static bool InsertCapabilities(const std::string& device_id,
struct sender_info* info = new struct sender_info;
info->device_id = device_id;
info->msg_id = msg_id;
+
+ if (!AppControlManager::GetAppControlManager().CheckAppControl(
+ device_id, mdgmgr->capmgr_, data, datasize)) {
+ LOG(ERROR) << "The appcontrol is not valid";
+ return;
+ }
+
if (!AppControlManager::GetAppControlManager().LaunchApplication(
data, datasize, info))
LOG(ERROR) << "Failed to launch application";
delete info;
}
- std::vector<RemoteDevice> dev_list = DBManager::SelectDevice();
+ std::vector<RemoteDevice> dev_list = DBManager::SelectDevices();
for (auto& dev : dev_list) {
switch (event_type) {
case PackageEventListener::EventType::INSTALL: