mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
aux/android: More null checks
This commit is contained in:
parent
f6aff9196a
commit
b2f751ae99
|
@ -25,11 +25,30 @@ getAppInfo(std::string const &packageName, jobject application_context)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto context = Context{application_context};
|
auto context = Context{application_context};
|
||||||
|
if (context.isNull()) {
|
||||||
|
U_LOG_E("getAppInfo: application_context was null");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
auto packageManager =
|
auto packageManager =
|
||||||
PackageManager{context.getPackageManager()};
|
PackageManager{context.getPackageManager()};
|
||||||
|
if (packageManager.isNull()) {
|
||||||
|
U_LOG_E(
|
||||||
|
"getAppInfo: "
|
||||||
|
"application_context.getPackageManager() returned "
|
||||||
|
"null");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
auto packageInfo = packageManager.getPackageInfo(
|
auto packageInfo = packageManager.getPackageInfo(
|
||||||
packageName, PackageManager::GET_META_DATA |
|
packageName, PackageManager::GET_META_DATA |
|
||||||
PackageManager::GET_SHARED_LIBRARY_FILES);
|
PackageManager::GET_SHARED_LIBRARY_FILES);
|
||||||
|
|
||||||
|
if (packageInfo.isNull()) {
|
||||||
|
U_LOG_E(
|
||||||
|
"getAppInfo: "
|
||||||
|
"application_context.getPackageManager()."
|
||||||
|
"getPackaegInfo() returned null");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
return packageInfo.getApplicationInfo();
|
return packageInfo.getApplicationInfo();
|
||||||
} catch (std::exception const &e) {
|
} catch (std::exception const &e) {
|
||||||
U_LOG_E("Could get App Info: %s", e.what());
|
U_LOG_E("Could get App Info: %s", e.what());
|
||||||
|
|
Loading…
Reference in a new issue