From 69df1ee362df0f42aef43eebaa4c18f8998be37c Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Sun, 4 Sep 2022 12:19:26 -0700 Subject: [PATCH] Device Info Summary: Utility class to obtain device information. Reviewed By: antonk52 Differential Revision: D39054479 fbshipit-source-id: 9e237e2a45cf46ceb5fb8fd8a9da5d87837e61b6 --- .../FlipperReactDeviceInfo.cpp | 51 +++++++++++++++++++ .../FlipperReactDeviceInfo.h | 25 +++++++++ 2 files changed, 76 insertions(+) create mode 100644 react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.cpp create mode 100644 react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.h diff --git a/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.cpp b/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.cpp new file mode 100644 index 000000000..f30672a12 --- /dev/null +++ b/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "FlipperReactDeviceInfo.h" + +#include +#include + +using namespace winrt::Windows::Foundation; + +namespace facebook { +namespace flipper { + +std::string FlipperReactDeviceInfo::getDevice() { + try { + return winrt::to_string( + winrt::Windows::Security::ExchangeActiveSyncProvisioning:: + EasClientDeviceInformation() + .SystemProductName()); + } catch (...) { + return "unknown"; + } +} +std::string FlipperReactDeviceInfo::getDeviceId() { + try { + return winrt::to_string( + winrt::Windows::Security::ExchangeActiveSyncProvisioning:: + EasClientDeviceInformation() + .SystemSku()); + } catch (...) { + return "unknown"; + } +} +std::string FlipperReactDeviceInfo::getHost() { + return "localhost"; +} +std::string FlipperReactDeviceInfo::getAppName() { + return winrt::to_string( + winrt::Windows::ApplicationModel::Package::Current().DisplayName()); +} +std::string FlipperReactDeviceInfo::getAppId() { + return winrt::to_string( + winrt::Windows::ApplicationModel::Package::Current().Id().Name()); +} + +} // namespace flipper +} // namespace facebook diff --git a/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.h b/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.h new file mode 100644 index 000000000..e1ed2a084 --- /dev/null +++ b/react-native/react-native-flipper/windows/ReactNativeFlipper/FlipperReactDeviceInfo.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +namespace facebook { +namespace flipper { + +class FlipperReactDeviceInfo { + public: + std::string getDevice(); + std::string getDeviceId(); + std::string getHost(); + std::string getAppName(); + std::string getAppId(); +}; + +} // namespace flipper +} // namespace facebook