Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: platform-tools
- name: Install NDK
run: |
java -version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ jobs:
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
packages: platform-tools
- name: Install NDK
run: |
java -version
Expand Down
1 change: 1 addition & 0 deletions cmake/MSTelemetryConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if(@MATSDK_CONFIG_STATIC_PACKAGE@)
SQLite3::SQLite3
"@MATSDK_SQLITE_PROVIDER_RESOLVED@"
SQLite3
LEGACY_TARGET SQLite::SQLite3
${_matsdk_package_sqlite_args})
matsdk_add_package_system_dependency(
MSTelemetry::zlib_dependency
Expand Down
8 changes: 7 additions & 1 deletion cmake/MatsdkDependencyTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function(matsdk_add_package_system_dependency dependency_target canonical_target
endif()

set(options APPLE_SYSTEM)
set(one_value_args APPLE_LIBRARY)
set(one_value_args APPLE_LIBRARY LEGACY_TARGET)
cmake_parse_arguments(MATSDK_PACKAGE_DEP "${options}" "${one_value_args}" "" ${ARGN})

if(MATSDK_PACKAGE_DEP_APPLE_SYSTEM)
Expand All @@ -35,6 +35,12 @@ function(matsdk_add_package_system_dependency dependency_target canonical_target
elseif(NOT TARGET "${canonical_target}")
find_dependency(${package_name})
endif()
if(NOT TARGET "${canonical_target}"
AND DEFINED MATSDK_PACKAGE_DEP_LEGACY_TARGET
AND TARGET "${MATSDK_PACKAGE_DEP_LEGACY_TARGET}")
matsdk_add_interface_dependency(
"${canonical_target}" "${MATSDK_PACKAGE_DEP_LEGACY_TARGET}")
endif()
if(NOT TARGET "${canonical_target}")
message(FATAL_ERROR
"${package_name} did not create the required ${canonical_target} target.")
Expand Down
12 changes: 9 additions & 3 deletions lib/offline/LogSessionDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ namespace MAT_NS_BEGIN

void LogSessionDataProvider::DeleteLogSessionDataFromFile()
{
std::string sessionPath = m_cacheFilePath.empty() ? "" : (m_cacheFilePath + ".ses").c_str();
std::string sessionPath =
(m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses";
if (!sessionPath.empty() && MAT::FileExists(sessionPath.c_str()))
{
MAT::FileDelete(sessionPath.c_str());
Expand All @@ -108,7 +109,8 @@ namespace MAT_NS_BEGIN
{
uint64_t sessionFirstTimeLaunch = 0;
std::string sessionSDKUid;
std::string sessionPath = m_cacheFilePath.empty() ? "" : (m_cacheFilePath + ".ses").c_str();
std::string sessionPath =
(m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses";
if (!sessionPath.empty())
{
if (MAT::FileExists(sessionPath.c_str()))
Expand All @@ -127,6 +129,11 @@ namespace MAT_NS_BEGIN
writeFileContents(sessionPath, sessionFirstTimeLaunch, sessionSDKUid);
}
}
else if (m_cacheFilePath == ":memory:")
{
sessionFirstTimeLaunch = PAL::getUtcSystemTimeMs();
sessionSDKUid = PAL::generateUuidString();
}
m_logSessionData.reset(new LogSessionData(sessionFirstTimeLaunch, sessionSDKUid));
}

Expand Down Expand Up @@ -209,4 +216,3 @@ namespace MAT_NS_BEGIN
}
}
MAT_NS_END

30 changes: 28 additions & 2 deletions tests/functests/LogSessionDataFuncTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ using namespace MAT;

const std::string SessionFileArgument = "test";
const char* const SessionFile = "test.ses";
const char* const MemorySessionFile = ":memory:.ses";

class LogSessionDataFuncTests : public ::testing::Test
{
void CleanupLocalSessionFile()
{
if (MAT::FileExists(SessionFile))
for (const auto* sessionFile : {SessionFile, MemorySessionFile})
{
MAT::FileDelete(SessionFile);
if (MAT::FileExists(sessionFile))
{
MAT::FileDelete(sessionFile);
}
}
}

Expand Down Expand Up @@ -76,6 +80,28 @@ TEST_F(LogSessionDataFuncTests, Constructor_SessionFile_FileCreated)
ASSERT_TRUE(MAT::FileExists(SessionFile));
}

TEST_F(LogSessionDataFuncTests, Constructor_InMemoryCache_NoSessionFileCreated)
{
auto logSessionDataProvider = LogSessionDataProvider(":memory:");
logSessionDataProvider.CreateLogSessionData();
const auto* logSessionData = logSessionDataProvider.GetLogSessionData();
ASSERT_NE(logSessionData, nullptr);
EXPECT_GT(logSessionData->getSessionFirstTime(), 0ull);
EXPECT_FALSE(logSessionData->getSessionSDKUid().empty());
const auto sessionSDKUid = logSessionData->getSessionSDKUid();
EXPECT_FALSE(MAT::FileExists(MemorySessionFile));

logSessionDataProvider.ResetLogSessionData();
logSessionData = logSessionDataProvider.GetLogSessionData();
ASSERT_NE(logSessionData, nullptr);
EXPECT_GT(logSessionData->getSessionFirstTime(), 0ull);
EXPECT_FALSE(logSessionData->getSessionSDKUid().empty());
EXPECT_NE(logSessionData->getSessionSDKUid(), sessionSDKUid);
EXPECT_FALSE(MAT::FileExists(MemorySessionFile));
logSessionDataProvider.DeleteLogSessionData();
EXPECT_FALSE(MAT::FileExists(MemorySessionFile));
}

TEST_F(LogSessionDataFuncTests, Constructor_ValidSessionFileExists_MembersSetToExistingFile)
{
const std::string validSessionFirstTime{ "123456" };
Expand Down
Loading