#include <app_install_helper.h>
#include <memory.h>
-#include <sm_db.h>
#include <sm_request.h>
#include <sm_api.h>
#include <temp_test_user.h>
#include <synchronization_pipe.h>
+#include <dpl/test/safe_cleanup.h>
class ScopedInstaller {
public:
ScopedInstaller(const AppInstallHelper &app, bool requestUid = true)
: m_appId(app.getAppId()),
m_uid(app.getUID()),
+ m_installType(app.getInstallType()),
m_shouldUninstall(true),
m_requestUid(requestUid),
m_creatorPid(getpid())
ScopedInstaller(ScopedInstaller &&other)
: m_appId(std::move(other.m_appId)),
m_uid(other.m_uid),
+ m_installType(other.m_installType),
m_shouldUninstall(other.m_shouldUninstall),
m_requestUid(other.m_requestUid),
m_creatorPid(other.m_creatorPid)
virtual ~ScopedInstaller() {
if (m_creatorPid == getpid())
- uninstallApp();
+ {
+ SafeCleanup::run([this]{ uninstallApp(); });
+ }
}
void uninstallApp() {
uninstReq.setAppId(m_appId);
if (m_requestUid)
uninstReq.setUid(m_uid);
-
+ if (m_installType != SM_APP_INSTALL_NONE)
+ uninstReq.setInstallType(m_installType);
SecurityManagerTest::Api::uninstall(uninstReq);
m_shouldUninstall = false;
}
protected:
std::string m_appId;
uid_t m_uid;
+ app_install_type m_installType;
bool m_shouldUninstall;
bool m_requestUid;
pid_t m_creatorPid;