Clean temp files manually in mobile STK
This commit is contained in:
parent
00c7bf561e
commit
db95d2f88f
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include "addons/addons_manager.hpp"
|
#include "addons/addons_manager.hpp"
|
||||||
|
#include "io/file_manager.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
#include "audio/sfx_manager.hpp"
|
#include "audio/sfx_manager.hpp"
|
||||||
@ -181,20 +182,28 @@ bool EventHandler::OnEvent (const SEvent &event)
|
|||||||
if (cmd == APP_CMD_PAUSE || cmd == APP_CMD_LOST_FOCUS)
|
if (cmd == APP_CMD_PAUSE || cmd == APP_CMD_LOST_FOCUS)
|
||||||
{
|
{
|
||||||
// Make sure that pause/unpause is executed only once
|
// Make sure that pause/unpause is executed only once
|
||||||
if (music_manager && device->isWindowMinimized() == device->isWindowFocused())
|
if (device->isWindowMinimized() == device->isWindowFocused())
|
||||||
{
|
{
|
||||||
|
if (music_manager)
|
||||||
music_manager->pauseMusic();
|
music_manager->pauseMusic();
|
||||||
|
if (SFXManager::get())
|
||||||
SFXManager::get()->pauseAll();
|
SFXManager::get()->pauseAll();
|
||||||
}
|
|
||||||
PlayerManager::get()->save();
|
PlayerManager::get()->save();
|
||||||
if (addons_manager->hasDownloadedIcons())
|
if (addons_manager->hasDownloadedIcons())
|
||||||
addons_manager->saveInstalled();
|
addons_manager->saveInstalled();
|
||||||
|
// Clean temp files manually as destructor of file manager
|
||||||
|
// won't be called at all in mobile if user just press home
|
||||||
|
// button
|
||||||
|
file_manager->cleanTempFiles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (cmd == APP_CMD_RESUME || cmd == APP_CMD_GAINED_FOCUS)
|
else if (cmd == APP_CMD_RESUME || cmd == APP_CMD_GAINED_FOCUS)
|
||||||
{
|
{
|
||||||
if (music_manager && device->isWindowActive())
|
if (device->isWindowActive())
|
||||||
{
|
{
|
||||||
|
if (music_manager)
|
||||||
music_manager->resumeMusic();
|
music_manager->resumeMusic();
|
||||||
|
if (SFXManager::get())
|
||||||
SFXManager::get()->resumeAll();
|
SFXManager::get()->resumeAll();
|
||||||
// Improve rubber banding effects of rewinders when going
|
// Improve rubber banding effects of rewinders when going
|
||||||
// back to phone, because the smooth timer is paused
|
// back to phone, because the smooth timer is paused
|
||||||
|
@ -453,6 +453,20 @@ void FileManager::reinitAfterDownloadAssets()
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
FileManager::~FileManager()
|
FileManager::~FileManager()
|
||||||
|
{
|
||||||
|
cleanTempFiles();
|
||||||
|
// Clean up rest of file manager
|
||||||
|
// =============================
|
||||||
|
popMusicSearchPath();
|
||||||
|
popModelSearchPath();
|
||||||
|
popTextureSearchPath();
|
||||||
|
popTextureSearchPath();
|
||||||
|
m_file_system->drop();
|
||||||
|
m_file_system = NULL;
|
||||||
|
} // ~FileManager
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void FileManager::cleanTempFiles()
|
||||||
{
|
{
|
||||||
// Clean up left-over files in addons/tmp that are older than 24h
|
// Clean up left-over files in addons/tmp that are older than 24h
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
@ -498,16 +512,7 @@ FileManager::~FileManager()
|
|||||||
removeFile(full_path);
|
removeFile(full_path);
|
||||||
|
|
||||||
} // for i in all files in tmp
|
} // for i in all files in tmp
|
||||||
|
} // cleanTempFiles
|
||||||
// Clean up rest of file manager
|
|
||||||
// =============================
|
|
||||||
popMusicSearchPath();
|
|
||||||
popModelSearchPath();
|
|
||||||
popTextureSearchPath();
|
|
||||||
popTextureSearchPath();
|
|
||||||
m_file_system->drop();
|
|
||||||
m_file_system = NULL;
|
|
||||||
} // ~FileManager
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Returns true if the specified file exists.
|
/** Returns true if the specified file exists.
|
||||||
|
@ -245,7 +245,8 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::string& getCertBundleLocation() const
|
const std::string& getCertBundleLocation() const
|
||||||
{ return m_cert_bundle_location; }
|
{ return m_cert_bundle_location; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void cleanTempFiles();
|
||||||
}; // FileManager
|
}; // FileManager
|
||||||
|
|
||||||
extern FileManager* file_manager;
|
extern FileManager* file_manager;
|
||||||
|
@ -130,18 +130,26 @@ float MainLoop::getLimitedDt()
|
|||||||
if (first_out_focus)
|
if (first_out_focus)
|
||||||
{
|
{
|
||||||
first_out_focus = false;
|
first_out_focus = false;
|
||||||
|
if (music_manager)
|
||||||
music_manager->pauseMusic();
|
music_manager->pauseMusic();
|
||||||
|
if (SFXManager::get())
|
||||||
SFXManager::get()->pauseAll();
|
SFXManager::get()->pauseAll();
|
||||||
PlayerManager::get()->save();
|
PlayerManager::get()->save();
|
||||||
if (addons_manager->hasDownloadedIcons())
|
if (addons_manager->hasDownloadedIcons())
|
||||||
addons_manager->saveInstalled();
|
addons_manager->saveInstalled();
|
||||||
|
// Clean temp files manually as destructor of file manager
|
||||||
|
// won't be called at all in mobile if user just press home
|
||||||
|
// button
|
||||||
|
file_manager->cleanTempFiles();
|
||||||
}
|
}
|
||||||
dev->run();
|
dev->run();
|
||||||
win_active = dev->isWindowActive();
|
win_active = dev->isWindowActive();
|
||||||
has_focus = dev->isWindowFocused();
|
has_focus = dev->isWindowFocused();
|
||||||
if (has_focus && win_active)
|
if (has_focus && win_active)
|
||||||
{
|
{
|
||||||
|
if (music_manager)
|
||||||
music_manager->resumeMusic();
|
music_manager->resumeMusic();
|
||||||
|
if (SFXManager::get())
|
||||||
SFXManager::get()->resumeAll();
|
SFXManager::get()->resumeAll();
|
||||||
// Improve rubber banding effects of rewinders when going
|
// Improve rubber banding effects of rewinders when going
|
||||||
// back to phone, because the smooth timer is paused
|
// back to phone, because the smooth timer is paused
|
||||||
|
Loading…
Reference in New Issue
Block a user