mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Cleanup DeviceInfo
PiperOrigin-RevId: 891750619
This commit is contained in:
committed by
Lasan Mahaliyana
parent
111f9a5275
commit
981d7db305
@@ -49,27 +49,20 @@
|
||||
}
|
||||
|
||||
- (void)testGetDownloadPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetDownloadPath().value().GetPath().c_str()));
|
||||
XCTAssertNotNil(@(_deviceInfo->GetDownloadPath().GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testGetLocalAppDataPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetLocalAppDataPath().value().GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testGetCommonAppDataPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetCommonAppDataPath().value().GetPath().c_str()));
|
||||
XCTAssertNotNil(
|
||||
@(_deviceInfo->GetLocalAppDataPath(nearby::FilePath("sub_path")).GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testGetTemporaryPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetTemporaryPath().value().GetPath().c_str()));
|
||||
XCTAssertNotNil(@(_deviceInfo->GetTemporaryPath().GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testGetLogPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetLogPath().value().GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testGetCrashDumpPath {
|
||||
XCTAssertNotNil(@(_deviceInfo->GetCrashDumpPath().value().GetPath().c_str()));
|
||||
XCTAssertNotNil(@(_deviceInfo->GetLogPath().GetPath().c_str()));
|
||||
}
|
||||
|
||||
- (void)testIsScreenLocked {
|
||||
|
||||
@@ -34,17 +34,13 @@ class DeviceInfo : public api::DeviceInfo {
|
||||
|
||||
api::DeviceInfo::OsType GetOsType() const override;
|
||||
|
||||
std::optional<FilePath> GetDownloadPath() const override;
|
||||
FilePath GetDownloadPath() const override;
|
||||
|
||||
std::optional<FilePath> GetLocalAppDataPath() const override;
|
||||
FilePath GetLocalAppDataPath(FilePath sub_path) const override;
|
||||
|
||||
std::optional<FilePath> GetCommonAppDataPath() const override;
|
||||
FilePath GetTemporaryPath() const override;
|
||||
|
||||
std::optional<FilePath> GetTemporaryPath() const override;
|
||||
|
||||
std::optional<FilePath> GetLogPath() const override;
|
||||
|
||||
std::optional<FilePath> GetCrashDumpPath() const override;
|
||||
FilePath GetLogPath() const override;
|
||||
|
||||
bool IsScreenLocked() const override;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ api::DeviceInfo::OsType DeviceInfo::GetOsType() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetDownloadPath() const {
|
||||
FilePath DeviceInfo::GetDownloadPath() const {
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
|
||||
NSError *error = nil;
|
||||
@@ -90,30 +90,24 @@ std::optional<FilePath> DeviceInfo::GetDownloadPath() const {
|
||||
error:&error];
|
||||
if (!downloadsURL) {
|
||||
GNCLoggerError(@"Failed to get download path: %@", error);
|
||||
return std::nullopt;
|
||||
return GetTemporaryPath();
|
||||
}
|
||||
|
||||
return FilePath(absl::string_view([downloadsURL.path cString]));
|
||||
}
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetLocalAppDataPath() const {
|
||||
return FilePath(absl::string_view([GNCLocalAppDataPath().path cString]));
|
||||
FilePath DeviceInfo::GetLocalAppDataPath(FilePath sub_path) const {
|
||||
return FilePath(absl::string_view([GNCLocalAppDataPath().path cString])).append(sub_path);
|
||||
}
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetCommonAppDataPath() const { return GetLocalAppDataPath(); }
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetTemporaryPath() const {
|
||||
FilePath DeviceInfo::GetTemporaryPath() const {
|
||||
return FilePath(absl::string_view([NSTemporaryDirectory() cString]));
|
||||
}
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetLogPath() const {
|
||||
FilePath DeviceInfo::GetLogPath() const {
|
||||
return FilePath(absl::string_view([GNCLogPath().path cString]));
|
||||
}
|
||||
|
||||
std::optional<FilePath> DeviceInfo::GetCrashDumpPath() const {
|
||||
return FilePath(absl::string_view([GNCCrashDumpPath().path cString]));
|
||||
}
|
||||
|
||||
bool DeviceInfo::IsScreenLocked() const { return false; }
|
||||
|
||||
void DeviceInfo::RegisterScreenLockedListener(
|
||||
|
||||
Reference in New Issue
Block a user