mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +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 {
|
||||
auto context = Context{application_context};
|
||||
if (context.isNull()) {
|
||||
U_LOG_E("getAppInfo: application_context was null");
|
||||
return {};
|
||||
}
|
||||
auto packageManager =
|
||||
PackageManager{context.getPackageManager()};
|
||||
if (packageManager.isNull()) {
|
||||
U_LOG_E(
|
||||
"getAppInfo: "
|
||||
"application_context.getPackageManager() returned "
|
||||
"null");
|
||||
return {};
|
||||
}
|
||||
auto packageInfo = packageManager.getPackageInfo(
|
||||
packageName, PackageManager::GET_META_DATA |
|
||||
PackageManager::GET_SHARED_LIBRARY_FILES);
|
||||
|
||||
if (packageInfo.isNull()) {
|
||||
U_LOG_E(
|
||||
"getAppInfo: "
|
||||
"application_context.getPackageManager()."
|
||||
"getPackaegInfo() returned null");
|
||||
return {};
|
||||
}
|
||||
return packageInfo.getApplicationInfo();
|
||||
} catch (std::exception const &e) {
|
||||
U_LOG_E("Could get App Info: %s", e.what());
|
||||
|
|
Loading…
Reference in a new issue