mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fixed crashpad db creation failure and changed root to CommonAppData. Changed captured Nearby Share Info to save to CommonAppData. Changed Clearcut root to CommonAppData.
PiperOrigin-RevId: 506528040
This commit is contained in:
committed by
Copybara-Service
parent
270aad8ca8
commit
3d9ce368ff
@@ -66,7 +66,7 @@ std::filesystem::path DeviceInfoImpl::GetDownloadPath() const {
|
||||
|
||||
std::filesystem::path DeviceInfoImpl::GetAppDataPath() const {
|
||||
std::optional<std::filesystem::path> path =
|
||||
device_info_impl_->GetAppDataPath();
|
||||
device_info_impl_->GetLocalAppDataPath();
|
||||
if (path.has_value()) {
|
||||
return *path;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ class DeviceInfo : public api::DeviceInfo {
|
||||
|
||||
std::optional<std::filesystem::path> GetDownloadPath() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetAppDataPath() const override;
|
||||
std::optional<std::filesystem::path> GetLocalAppDataPath() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetCommonAppDataPath() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetTemporaryPath() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetLogPath() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetCrashDumpPath() const override;
|
||||
|
||||
bool IsScreenLocked() const override;
|
||||
|
||||
void RegisterScreenLockedListener(
|
||||
|
||||
@@ -43,7 +43,11 @@ std::optional<std::filesystem::path> DeviceInfo::GetDownloadPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetAppDataPath() const {
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetLocalAppDataPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetCommonAppDataPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
@@ -55,6 +59,10 @@ std::optional<std::filesystem::path> DeviceInfo::GetLogPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetCrashDumpPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
bool DeviceInfo::IsScreenLocked() const { return false; }
|
||||
|
||||
void DeviceInfo::RegisterScreenLockedListener(
|
||||
|
||||
@@ -46,9 +46,11 @@ class DeviceInfo {
|
||||
|
||||
// Gets known paths of current user.
|
||||
virtual std::optional<std::filesystem::path> GetDownloadPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetAppDataPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetLocalAppDataPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetCommonAppDataPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetTemporaryPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetLogPath() const = 0;
|
||||
virtual std::optional<std::filesystem::path> GetCrashDumpPath() const = 0;
|
||||
|
||||
// Monitor screen status
|
||||
virtual bool IsScreenLocked() const = 0;
|
||||
|
||||
@@ -59,7 +59,11 @@ class DeviceInfo : public api::DeviceInfo {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> GetAppDataPath() const override {
|
||||
std::optional<std::filesystem::path> GetLocalAppDataPath() const override {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> GetCommonAppDataPath() const override {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
@@ -71,6 +75,10 @@ class DeviceInfo : public api::DeviceInfo {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> GetCrashDumpPath() const override {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
bool IsScreenLocked() const override { return false; }
|
||||
|
||||
void RegisterScreenLockedListener(
|
||||
|
||||
@@ -52,6 +52,8 @@ using IAsyncOperation = winrt::Windows::Foundation::IAsyncOperation<T>;
|
||||
constexpr char window_class_name[] = "NearbySharingDLL_MessageWindowClass";
|
||||
constexpr char window_name[] = "NearbySharingDLL_MessageWindow";
|
||||
constexpr char kLogsRelativePath[] = "Google\\Nearby\\Sharing\\Logs";
|
||||
constexpr char kCrashDumpsRelativePath[] =
|
||||
"Google\\Nearby\\Sharing\\CrashDumps";
|
||||
|
||||
namespace {
|
||||
// This WindowProc method must be static for the successful initialization of
|
||||
@@ -352,7 +354,7 @@ std::optional<std::filesystem::path> DeviceInfo::GetDownloadPath() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetAppDataPath() const {
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetLocalAppDataPath() const {
|
||||
std::string path;
|
||||
path.resize(MAX_PATH);
|
||||
HRESULT result = SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr,
|
||||
@@ -365,15 +367,28 @@ std::optional<std::filesystem::path> DeviceInfo::GetAppDataPath() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetCommonAppDataPath() const {
|
||||
PWSTR path;
|
||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT,
|
||||
/*hToken=*/nullptr, &path);
|
||||
if (result == S_OK) {
|
||||
std::wstring download_path{path};
|
||||
CoTaskMemFree(path);
|
||||
return std::filesystem::path(download_path);
|
||||
}
|
||||
|
||||
CoTaskMemFree(path);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetTemporaryPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetLogPath() const {
|
||||
PWSTR path;
|
||||
HRESULT result =
|
||||
SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT,
|
||||
/*hToken*/nullptr, &path);
|
||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT,
|
||||
/*hToken=*/nullptr, &path);
|
||||
if (result == S_OK) {
|
||||
std::filesystem::path prefixPath = path;
|
||||
CoTaskMemFree(path);
|
||||
@@ -383,6 +398,19 @@ std::optional<std::filesystem::path> DeviceInfo::GetLogPath() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetCrashDumpPath() const {
|
||||
PWSTR path;
|
||||
HRESULT result = SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT,
|
||||
/*hToken=*/nullptr, &path);
|
||||
if (result == S_OK) {
|
||||
std::filesystem::path prefixPath = path;
|
||||
CoTaskMemFree(path);
|
||||
return std::filesystem::path(prefixPath / kCrashDumpsRelativePath);
|
||||
}
|
||||
CoTaskMemFree(path);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool DeviceInfo::IsScreenLocked() const {
|
||||
DWORD session_id = WTSGetActiveConsoleSessionId();
|
||||
WTS_INFO_CLASS wts_info_class = WTSSessionInfoEx;
|
||||
|
||||
@@ -44,9 +44,11 @@ class DeviceInfo : public api::DeviceInfo {
|
||||
std::optional<std::string> GetProfileUserName() const override;
|
||||
|
||||
std::optional<std::filesystem::path> GetDownloadPath() const override;
|
||||
std::optional<std::filesystem::path> GetAppDataPath() const override;
|
||||
std::optional<std::filesystem::path> GetLocalAppDataPath() const override;
|
||||
std::optional<std::filesystem::path> GetCommonAppDataPath() const override;
|
||||
std::optional<std::filesystem::path> GetTemporaryPath() const override;
|
||||
std::optional<std::filesystem::path> GetLogPath() const override;
|
||||
std::optional<std::filesystem::path> GetCrashDumpPath() const override;
|
||||
|
||||
bool IsScreenLocked() const override;
|
||||
void RegisterScreenLockedListener(
|
||||
|
||||
@@ -53,8 +53,8 @@ TEST(DeviceInfo, DISABLED_GetProfileUserName) {
|
||||
EXPECT_TRUE(DeviceInfo().GetProfileUserName().has_value());
|
||||
}
|
||||
|
||||
TEST(DeviceInfo, DISABLED_GetAppDataPath) {
|
||||
EXPECT_TRUE(DeviceInfo().GetAppDataPath().has_value());
|
||||
TEST(DeviceInfo, DISABLED_GetLocalAppDataPath) {
|
||||
EXPECT_TRUE(DeviceInfo().GetLocalAppDataPath().has_value());
|
||||
}
|
||||
|
||||
TEST(DeviceInfo, DISABLED_GetDownloadPath) {
|
||||
|
||||
Reference in New Issue
Block a user