mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Migrate device_info from location/nearby to third_party/nearby
PiperOrigin-RevId: 504935151
This commit is contained in:
committed by
Copybara-Service
parent
54fec27c00
commit
a0692e6306
@@ -25,6 +25,7 @@ objc_library(
|
||||
"ble.mm",
|
||||
"bluetooth_adapter.mm",
|
||||
"crypto.mm",
|
||||
"device_info.mm",
|
||||
"log_message.mm",
|
||||
"multi_thread_executor.mm",
|
||||
"platform.mm",
|
||||
@@ -36,6 +37,7 @@ objc_library(
|
||||
hdrs = [
|
||||
"ble.h",
|
||||
"bluetooth_adapter.h",
|
||||
"device_info.h",
|
||||
"log_message.h",
|
||||
"multi_thread_executor.h",
|
||||
"scheduled_executor.h",
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef PLATFORM_IMPL_APPLE_DEVICE_INFO_H_
|
||||
#define PLATFORM_IMPL_APPLE_DEVICE_INFO_H_
|
||||
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace apple {
|
||||
|
||||
class DeviceInfo : public api::DeviceInfo {
|
||||
public:
|
||||
std::optional<std::u16string> GetOsDeviceName() const override;
|
||||
|
||||
api::DeviceInfo::DeviceType GetDeviceType() const override;
|
||||
|
||||
api::DeviceInfo::OsType GetOsType() const override;
|
||||
|
||||
std::optional<std::u16string> GetFullName() const override;
|
||||
std::optional<std::u16string> GetGivenName() const override;
|
||||
std::optional<std::u16string> GetLastName() const override;
|
||||
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> GetTemporaryPath() const override;
|
||||
|
||||
bool IsScreenLocked() const override;
|
||||
|
||||
void RegisterScreenLockedListener(
|
||||
absl::string_view listener_name,
|
||||
std::function<void(api::DeviceInfo::ScreenStatus)> callback) override;
|
||||
|
||||
void UnregisterScreenLockedListener(absl::string_view listener_name) override;
|
||||
};
|
||||
|
||||
} // namespace apple
|
||||
} // namespace nearby
|
||||
|
||||
#endif // PLATFORM_IMPL_APPLE_DEVICE_INFO_H_
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "internal/platform/implementation/apple/device_info.h"
|
||||
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace apple {
|
||||
|
||||
std::optional<std::u16string> DeviceInfo::GetOsDeviceName() const { return u"OS Device Name"; }
|
||||
|
||||
api::DeviceInfo::DeviceType DeviceInfo::GetDeviceType() const {
|
||||
return api::DeviceInfo::DeviceType::kLaptop;
|
||||
}
|
||||
|
||||
api::DeviceInfo::OsType DeviceInfo::GetOsType() const { return api::DeviceInfo::OsType::kIos; }
|
||||
|
||||
std::optional<std::u16string> DeviceInfo::GetFullName() const { return u"Full Name"; }
|
||||
std::optional<std::u16string> DeviceInfo::GetGivenName() const { return u"Given Name"; }
|
||||
std::optional<std::u16string> DeviceInfo::GetLastName() const { return u"Last Name"; }
|
||||
std::optional<std::string> DeviceInfo::GetProfileUserName() const { return "Username"; }
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetDownloadPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetAppDataPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetTemporaryPath() const {
|
||||
return std::filesystem::temp_directory_path();
|
||||
}
|
||||
|
||||
bool DeviceInfo::IsScreenLocked() const { return false; }
|
||||
|
||||
void DeviceInfo::RegisterScreenLockedListener(
|
||||
absl::string_view listener_name, std::function<void(api::DeviceInfo::ScreenStatus)> callback) {}
|
||||
|
||||
void DeviceInfo::UnregisterScreenLockedListener(absl::string_view listener_name) {}
|
||||
|
||||
} // namespace apple
|
||||
} // namespace nearby
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "internal/platform/implementation/apple/ble.h"
|
||||
#include "internal/platform/implementation/apple/condition_variable.h"
|
||||
#include "internal/platform/implementation/apple/count_down_latch.h"
|
||||
#include "internal/platform/implementation/apple/device_info.h"
|
||||
#import "internal/platform/implementation/apple/log_message.h"
|
||||
#import "internal/platform/implementation/apple/multi_thread_executor.h"
|
||||
#include "internal/platform/implementation/apple/mutex.h"
|
||||
@@ -182,5 +183,10 @@ std::unique_ptr<Timer> ImplementationPlatform::CreateTimer() {
|
||||
return std::make_unique<apple::Timer>();
|
||||
}
|
||||
|
||||
// TODO(b/261511530): Add implementation.
|
||||
std::unique_ptr<nearby::api::DeviceInfo> ImplementationPlatform::CreateDeviceInfo() {
|
||||
return std::make_unique<apple::DeviceInfo>();
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user