Recreate libchildprocess after apk upgrade also when device has non-typical internal data dir
This commit is contained in:
parent
35b167a824
commit
ad8b30b5d3
@ -1478,11 +1478,12 @@ void CIrrDeviceAndroid::readApplicationInfo(ANativeActivity* activity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AndroidApplicationInfo& CIrrDeviceAndroid::getApplicationInfo()
|
const AndroidApplicationInfo& CIrrDeviceAndroid::getApplicationInfo(
|
||||||
|
ANativeActivity* activity)
|
||||||
{
|
{
|
||||||
if (Android != NULL && ApplicationInfo.initialized == false)
|
if (activity != NULL && ApplicationInfo.initialized == false)
|
||||||
{
|
{
|
||||||
readApplicationInfo(Android->activity);
|
readApplicationInfo(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApplicationInfo;
|
return ApplicationInfo;
|
||||||
|
@ -74,7 +74,6 @@ namespace irr
|
|||||||
virtual bool isGyroscopeActive();
|
virtual bool isGyroscopeActive();
|
||||||
virtual bool isGyroscopeAvailable();
|
virtual bool isGyroscopeAvailable();
|
||||||
virtual void setTextInputEnabled(bool enabled) {TextInputEnabled = enabled;}
|
virtual void setTextInputEnabled(bool enabled) {TextInputEnabled = enabled;}
|
||||||
virtual const AndroidApplicationInfo& getApplicationInfo();
|
|
||||||
|
|
||||||
class CCursorControl : public gui::ICursorControl
|
class CCursorControl : public gui::ICursorControl
|
||||||
{
|
{
|
||||||
@ -115,6 +114,8 @@ namespace irr
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void onCreate();
|
static void onCreate();
|
||||||
|
static const AndroidApplicationInfo& getApplicationInfo(
|
||||||
|
ANativeActivity* activity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
android_app* Android;
|
android_app* Android;
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <android/asset_manager.h>
|
#include <android/asset_manager.h>
|
||||||
#include <sys/statfs.h>
|
#include <sys/statfs.h>
|
||||||
|
|
||||||
|
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -488,7 +490,7 @@ void AssetsAndroid::removeData()
|
|||||||
if (file == m_stk_dir + "/.nomedia")
|
if (file == m_stk_dir + "/.nomedia")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Log::info("AssetsAndroid", "Deleting file: %s\n", file.c_str());
|
Log::info("AssetsAndroid", "Deleting file: %s", file.c_str());
|
||||||
|
|
||||||
if (m_file_manager->isDirectory(file))
|
if (m_file_manager->isDirectory(file))
|
||||||
{
|
{
|
||||||
@ -499,13 +501,19 @@ void AssetsAndroid::removeData()
|
|||||||
m_file_manager->removeFile(file);
|
m_file_manager->removeFile(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string data_path = getDataPath();
|
||||||
|
|
||||||
const std::string data_path = "/data/data/" ANDROID_PACKAGE_NAME;
|
if (!data_path.empty())
|
||||||
const std::string child_path = data_path + "/files/libchildprocess.so";
|
|
||||||
|
|
||||||
if (m_file_manager->fileExists(child_path))
|
|
||||||
{
|
{
|
||||||
m_file_manager->removeFile(child_path);
|
const std::string child_path = data_path + "/files/libchildprocess.so";
|
||||||
|
|
||||||
|
if (m_file_manager->fileExists(child_path))
|
||||||
|
{
|
||||||
|
Log::info("AssetsAndroid", "Deleting old libchildprocess: %s",
|
||||||
|
child_path.c_str());
|
||||||
|
m_file_manager->removeFile(child_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -595,3 +603,27 @@ std::string AssetsAndroid::getPreferredPath(const std::vector<std::string>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** Get a path for internal data directory
|
||||||
|
* \return Path for internal data directory or empty string when failed
|
||||||
|
*/
|
||||||
|
std::string AssetsAndroid::getDataPath()
|
||||||
|
{
|
||||||
|
std::string data_path = "/data/data/" ANDROID_PACKAGE_NAME;
|
||||||
|
|
||||||
|
if (access(data_path.c_str(), R_OK) != 0)
|
||||||
|
{
|
||||||
|
Log::warn("AssetsAndroid", "Cannot use standard data dir");
|
||||||
|
|
||||||
|
AndroidApplicationInfo application_info =
|
||||||
|
CIrrDeviceAndroid::getApplicationInfo(global_android_app->activity);
|
||||||
|
|
||||||
|
data_path = application_info.data_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(data_path.c_str(), R_OK) != 0)
|
||||||
|
{
|
||||||
|
data_path = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return data_path;
|
||||||
|
}
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
~AssetsAndroid() {};
|
~AssetsAndroid() {};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
static std::string getDataPath();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,8 +38,7 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "io/assets_android.hpp"
|
||||||
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -283,21 +282,8 @@ bool SeparateProcess::createChildProcess(const std::string& exe,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string data_path = "/data/data/" ANDROID_PACKAGE_NAME;
|
std::string data_path = AssetsAndroid::getDataPath();
|
||||||
std::string main_path = data_path + "/lib/libmain.so";
|
std::string main_path = data_path + "/lib/libmain.so";
|
||||||
|
|
||||||
if (access(main_path.c_str(), R_OK) != 0)
|
|
||||||
{
|
|
||||||
Log::warn("SeparateProcess", "Cannot use standard data dir");
|
|
||||||
|
|
||||||
CIrrDeviceAndroid* device = dynamic_cast<CIrrDeviceAndroid*>(
|
|
||||||
irr_driver->getDevice());
|
|
||||||
|
|
||||||
AndroidApplicationInfo application_info = device->getApplicationInfo();
|
|
||||||
|
|
||||||
data_path = application_info.data_dir;
|
|
||||||
main_path = data_path + "/lib/libmain.so";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data_path.empty() || access(main_path.c_str(), R_OK) != 0)
|
if (data_path.empty() || access(main_path.c_str(), R_OK) != 0)
|
||||||
{
|
{
|
||||||
@ -311,6 +297,8 @@ bool SeparateProcess::createChildProcess(const std::string& exe,
|
|||||||
|
|
||||||
if (access(child_path.c_str(), R_OK) != 0)
|
if (access(child_path.c_str(), R_OK) != 0)
|
||||||
{
|
{
|
||||||
|
Log::info("SeparateProcess", "Creating libchildprocess.so");
|
||||||
|
|
||||||
std::ifstream src(main_path, std::ios::binary);
|
std::ifstream src(main_path, std::ios::binary);
|
||||||
|
|
||||||
if (!src.good())
|
if (!src.good())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user