diff --git a/cpp/idevice++.xcodeproj/project.pbxproj b/cpp/idevice++.xcodeproj/project.pbxproj index ed47dc7..02133e8 100644 --- a/cpp/idevice++.xcodeproj/project.pbxproj +++ b/cpp/idevice++.xcodeproj/project.pbxproj @@ -7,10 +7,18 @@ objects = { /* Begin PBXBuildFile section */ + 396C57412EA7F5DC00188F4B /* application_listing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396C56B12EA7F53000188F4B /* application_listing.cpp */; }; + 396C57422EA7F5DC00188F4B /* condition_inducer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396C56B22EA7F53000188F4B /* condition_inducer.cpp */; }; + 396C57432EA7F5DC00188F4B /* device_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396C56B32EA7F53000188F4B /* device_info.cpp */; }; + 296C57412EA7F5DC00188F4B /* energy_monitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 296C56B12EA7F53000188F4B /* energy_monitor.cpp */; }; + 196C57442EA7F5DC00188F4B /* graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B32EA7F53000188F4B /* graphics.cpp */; }; 196C57452EA7F5DC00188F4B /* location_simulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B42EA7F53000188F4B /* location_simulation.cpp */; }; + 396C57442EA7F5DC00188F4B /* network_monitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396C56B42EA7F53000188F4B /* network_monitor.cpp */; }; + 196C57432EA7F5DC00188F4B /* notifications.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B22EA7F53000188F4B /* notifications.cpp */; }; 196C57462EA7F5DC00188F4B /* process_control.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B52EA7F53000188F4B /* process_control.cpp */; }; 196C57472EA7F5DC00188F4B /* remote_server.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B62EA7F53000188F4B /* remote_server.cpp */; }; 196C57482EA7F5DC00188F4B /* screenshot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B72EA7F53000188F4B /* screenshot.cpp */; }; + 396C57452EA7F5DC00188F4B /* sysmontap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396C56B52EA7F53000188F4B /* sysmontap.cpp */; }; 196C57492EA7F5DC00188F4B /* adapter_stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56B92EA7F53000188F4B /* adapter_stream.cpp */; }; 196C574A2EA7F5DC00188F4B /* app_service.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56BA2EA7F53000188F4B /* app_service.cpp */; }; 196C574B2EA7F5DC00188F4B /* core_device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56BB2EA7F53000188F4B /* core_device.cpp */; }; @@ -27,10 +35,18 @@ 196C57562EA7F5DC00188F4B /* rsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56C62EA7F53000188F4B /* rsd.cpp */; }; 196C57572EA7F5DC00188F4B /* tcp_callback_feeder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56C72EA7F53000188F4B /* tcp_callback_feeder.cpp */; }; 196C57582EA7F5DC00188F4B /* usbmuxd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 196C56C82EA7F53000188F4B /* usbmuxd.cpp */; }; + 396C57512EA7F5F400188F4B /* application_listing.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 396C56D12EA7F54900188F4B /* application_listing.hpp */; }; + 396C57522EA7F5F400188F4B /* condition_inducer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 396C56D22EA7F54900188F4B /* condition_inducer.hpp */; }; + 396C57532EA7F5F400188F4B /* device_info.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 396C56D32EA7F54900188F4B /* device_info.hpp */; }; + 296C57562EA7F5F400188F4B /* energy_monitor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 296C56DB2EA7F54900188F4B /* energy_monitor.hpp */; }; + 196C57582EA7F5F400188F4B /* graphics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56DD2EA7F54900188F4B /* graphics.hpp */; }; 196C57592EA7F5F400188F4B /* location_simulation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56DE2EA7F54900188F4B /* location_simulation.hpp */; }; + 396C57542EA7F5F400188F4B /* network_monitor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 396C56D42EA7F54900188F4B /* network_monitor.hpp */; }; + 196C57572EA7F5F400188F4B /* notifications.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56DC2EA7F54900188F4B /* notifications.hpp */; }; 196C575A2EA7F5F400188F4B /* process_control.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56DF2EA7F54900188F4B /* process_control.hpp */; }; 196C575B2EA7F5F400188F4B /* remote_server.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56E02EA7F54900188F4B /* remote_server.hpp */; }; 196C575C2EA7F5F400188F4B /* screenshot.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56E12EA7F54900188F4B /* screenshot.hpp */; }; + 396C57552EA7F5F400188F4B /* sysmontap.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 396C56D52EA7F54900188F4B /* sysmontap.hpp */; }; 196C575D2EA7F5F400188F4B /* adapter_stream.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56E32EA7F54900188F4B /* adapter_stream.hpp */; }; 196C575E2EA7F5F400188F4B /* app_service.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56E42EA7F54900188F4B /* app_service.hpp */; }; 196C575F2EA7F5F400188F4B /* bindings.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 196C56E52EA7F54900188F4B /* bindings.hpp */; }; @@ -56,10 +72,18 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 396C56B12EA7F53000188F4B /* application_listing.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = application_listing.cpp; sourceTree = ""; }; + 396C56B22EA7F53000188F4B /* condition_inducer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = condition_inducer.cpp; sourceTree = ""; }; + 396C56B32EA7F53000188F4B /* device_info.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = device_info.cpp; sourceTree = ""; }; + 296C56B12EA7F53000188F4B /* energy_monitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = energy_monitor.cpp; sourceTree = ""; }; + 196C56B32EA7F53000188F4B /* graphics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = graphics.cpp; sourceTree = ""; }; 196C56B42EA7F53000188F4B /* location_simulation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = location_simulation.cpp; sourceTree = ""; }; + 396C56B42EA7F53000188F4B /* network_monitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = network_monitor.cpp; sourceTree = ""; }; + 196C56B22EA7F53000188F4B /* notifications.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = notifications.cpp; sourceTree = ""; }; 196C56B52EA7F53000188F4B /* process_control.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = process_control.cpp; sourceTree = ""; }; 196C56B62EA7F53000188F4B /* remote_server.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = remote_server.cpp; sourceTree = ""; }; 196C56B72EA7F53000188F4B /* screenshot.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = screenshot.cpp; sourceTree = ""; }; + 396C56B52EA7F53000188F4B /* sysmontap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sysmontap.cpp; sourceTree = ""; }; 196C56B92EA7F53000188F4B /* adapter_stream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = adapter_stream.cpp; sourceTree = ""; }; 196C56BA2EA7F53000188F4B /* app_service.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = app_service.cpp; sourceTree = ""; }; 196C56BB2EA7F53000188F4B /* core_device.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = core_device.cpp; sourceTree = ""; }; @@ -76,10 +100,18 @@ 196C56C62EA7F53000188F4B /* rsd.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = rsd.cpp; sourceTree = ""; }; 196C56C72EA7F53000188F4B /* tcp_callback_feeder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = tcp_callback_feeder.cpp; sourceTree = ""; }; 196C56C82EA7F53000188F4B /* usbmuxd.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = usbmuxd.cpp; sourceTree = ""; }; + 396C56D12EA7F54900188F4B /* application_listing.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = application_listing.hpp; sourceTree = ""; }; + 396C56D22EA7F54900188F4B /* condition_inducer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = condition_inducer.hpp; sourceTree = ""; }; + 396C56D32EA7F54900188F4B /* device_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = device_info.hpp; sourceTree = ""; }; + 296C56DB2EA7F54900188F4B /* energy_monitor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = energy_monitor.hpp; sourceTree = ""; }; + 196C56DD2EA7F54900188F4B /* graphics.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = graphics.hpp; sourceTree = ""; }; 196C56DE2EA7F54900188F4B /* location_simulation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = location_simulation.hpp; sourceTree = ""; }; + 396C56D42EA7F54900188F4B /* network_monitor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = network_monitor.hpp; sourceTree = ""; }; + 196C56DC2EA7F54900188F4B /* notifications.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = notifications.hpp; sourceTree = ""; }; 196C56DF2EA7F54900188F4B /* process_control.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = process_control.hpp; sourceTree = ""; }; 196C56E02EA7F54900188F4B /* remote_server.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = remote_server.hpp; sourceTree = ""; }; 196C56E12EA7F54900188F4B /* screenshot.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = screenshot.hpp; sourceTree = ""; }; + 396C56D52EA7F54900188F4B /* sysmontap.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = sysmontap.hpp; sourceTree = ""; }; 196C56E32EA7F54900188F4B /* adapter_stream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = adapter_stream.hpp; sourceTree = ""; }; 196C56E42EA7F54900188F4B /* app_service.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = app_service.hpp; sourceTree = ""; }; 196C56E52EA7F54900188F4B /* bindings.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = bindings.hpp; sourceTree = ""; }; @@ -121,10 +153,18 @@ 196C56B82EA7F53000188F4B /* dvt */ = { isa = PBXGroup; children = ( + 396C56B12EA7F53000188F4B /* application_listing.cpp */, + 396C56B22EA7F53000188F4B /* condition_inducer.cpp */, + 396C56B32EA7F53000188F4B /* device_info.cpp */, + 296C56B12EA7F53000188F4B /* energy_monitor.cpp */, + 196C56B32EA7F53000188F4B /* graphics.cpp */, 196C56B42EA7F53000188F4B /* location_simulation.cpp */, + 396C56B42EA7F53000188F4B /* network_monitor.cpp */, + 196C56B22EA7F53000188F4B /* notifications.cpp */, 196C56B52EA7F53000188F4B /* process_control.cpp */, 196C56B62EA7F53000188F4B /* remote_server.cpp */, 196C56B72EA7F53000188F4B /* screenshot.cpp */, + 396C56B52EA7F53000188F4B /* sysmontap.cpp */, ); path = dvt; sourceTree = ""; @@ -156,10 +196,18 @@ 196C56E22EA7F54900188F4B /* dvt */ = { isa = PBXGroup; children = ( + 396C56D12EA7F54900188F4B /* application_listing.hpp */, + 396C56D22EA7F54900188F4B /* condition_inducer.hpp */, + 396C56D32EA7F54900188F4B /* device_info.hpp */, + 296C56DB2EA7F54900188F4B /* energy_monitor.hpp */, + 196C56DD2EA7F54900188F4B /* graphics.hpp */, 196C56DE2EA7F54900188F4B /* location_simulation.hpp */, + 396C56D42EA7F54900188F4B /* network_monitor.hpp */, + 196C56DC2EA7F54900188F4B /* notifications.hpp */, 196C56DF2EA7F54900188F4B /* process_control.hpp */, 196C56E02EA7F54900188F4B /* remote_server.hpp */, 196C56E12EA7F54900188F4B /* screenshot.hpp */, + 396C56D52EA7F54900188F4B /* sysmontap.hpp */, ); path = dvt; sourceTree = ""; @@ -235,10 +283,18 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 396C57512EA7F5F400188F4B /* application_listing.hpp in Headers */, + 396C57522EA7F5F400188F4B /* condition_inducer.hpp in Headers */, + 396C57532EA7F5F400188F4B /* device_info.hpp in Headers */, + 296C57562EA7F5F400188F4B /* energy_monitor.hpp in Headers */, + 196C57582EA7F5F400188F4B /* graphics.hpp in Headers */, 196C57592EA7F5F400188F4B /* location_simulation.hpp in Headers */, + 396C57542EA7F5F400188F4B /* network_monitor.hpp in Headers */, + 196C57572EA7F5F400188F4B /* notifications.hpp in Headers */, 196C575A2EA7F5F400188F4B /* process_control.hpp in Headers */, 196C575B2EA7F5F400188F4B /* remote_server.hpp in Headers */, 196C575C2EA7F5F400188F4B /* screenshot.hpp in Headers */, + 396C57552EA7F5F400188F4B /* sysmontap.hpp in Headers */, 196C575D2EA7F5F400188F4B /* adapter_stream.hpp in Headers */, 196C575E2EA7F5F400188F4B /* app_service.hpp in Headers */, 196C575F2EA7F5F400188F4B /* bindings.hpp in Headers */, @@ -346,10 +402,18 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 396C57412EA7F5DC00188F4B /* application_listing.cpp in Sources */, + 396C57422EA7F5DC00188F4B /* condition_inducer.cpp in Sources */, + 396C57432EA7F5DC00188F4B /* device_info.cpp in Sources */, + 296C57412EA7F5DC00188F4B /* energy_monitor.cpp in Sources */, + 196C57442EA7F5DC00188F4B /* graphics.cpp in Sources */, 196C57452EA7F5DC00188F4B /* location_simulation.cpp in Sources */, + 396C57442EA7F5DC00188F4B /* network_monitor.cpp in Sources */, + 196C57432EA7F5DC00188F4B /* notifications.cpp in Sources */, 196C57462EA7F5DC00188F4B /* process_control.cpp in Sources */, 196C57472EA7F5DC00188F4B /* remote_server.cpp in Sources */, 196C57482EA7F5DC00188F4B /* screenshot.cpp in Sources */, + 396C57452EA7F5DC00188F4B /* sysmontap.cpp in Sources */, 196C57492EA7F5DC00188F4B /* adapter_stream.cpp in Sources */, 196C574A2EA7F5DC00188F4B /* app_service.cpp in Sources */, 196C574B2EA7F5DC00188F4B /* core_device.cpp in Sources */, diff --git a/cpp/include/idevice++/dvt/energy_monitor.hpp b/cpp/include/idevice++/dvt/energy_monitor.hpp new file mode 100644 index 0000000..6af60fb --- /dev/null +++ b/cpp/include/idevice++/dvt/energy_monitor.hpp @@ -0,0 +1,51 @@ +// Jackson Coxson + +#pragma once +#include +#include +#include +#include +#include + +namespace IdeviceFFI { + +using EnergyMonitorPtr = + std::unique_ptr>; + +struct EnergySample { + uint32_t pid = 0; + int64_t timestamp = 0; + double total_energy = 0.0; + double cpu_energy = 0.0; + double gpu_energy = 0.0; + double networking_energy = 0.0; + double display_energy = 0.0; + double location_energy = 0.0; + double appstate_energy = 0.0; +}; + +class EnergyMonitor { + public: + static Result create(RemoteServer& server); + + Result start_sampling(const std::vector& pids); + Result stop_sampling(const std::vector& pids); + Result, FfiError> sample_attributes( + const std::vector& pids); + + ~EnergyMonitor() noexcept = default; + EnergyMonitor(EnergyMonitor&&) noexcept = default; + EnergyMonitor& operator=(EnergyMonitor&&) noexcept = default; + EnergyMonitor(const EnergyMonitor&) = delete; + EnergyMonitor& operator=(const EnergyMonitor&) = delete; + + EnergyMonitorHandle* raw() const noexcept { return handle_.get(); } + static EnergyMonitor adopt(EnergyMonitorHandle* h) noexcept { return EnergyMonitor(h); } + + private: + explicit EnergyMonitor(EnergyMonitorHandle* h) noexcept : handle_(h) {} + EnergyMonitorPtr handle_{}; +}; + +} // namespace IdeviceFFI diff --git a/cpp/include/idevice++/dvt/graphics.hpp b/cpp/include/idevice++/dvt/graphics.hpp new file mode 100644 index 0000000..05d16e8 --- /dev/null +++ b/cpp/include/idevice++/dvt/graphics.hpp @@ -0,0 +1,47 @@ +// Jackson Coxson + +#pragma once +#include +#include +#include +#include +#include + +namespace IdeviceFFI { + +using GraphicsPtr = + std::unique_ptr>; + +struct GraphicsSample { + uint64_t timestamp = 0; + double fps = 0.0; + uint64_t alloc_system_memory = 0; + uint64_t in_use_system_memory = 0; + uint64_t in_use_system_memory_driver = 0; + std::string gpu_bundle_name; + uint64_t recovery_count = 0; +}; + +class Graphics { + public: + static Result create(RemoteServer& server); + + Result start(double interval); + Result stop(); + Result next_sample(); + + ~Graphics() noexcept = default; + Graphics(Graphics&&) noexcept = default; + Graphics& operator=(Graphics&&) noexcept = default; + Graphics(const Graphics&) = delete; + Graphics& operator=(const Graphics&) = delete; + + GraphicsHandle* raw() const noexcept { return handle_.get(); } + static Graphics adopt(GraphicsHandle* h) noexcept { return Graphics(h); } + + private: + explicit Graphics(GraphicsHandle* h) noexcept : handle_(h) {} + GraphicsPtr handle_{}; +}; + +} // namespace IdeviceFFI diff --git a/cpp/include/idevice++/dvt/notifications.hpp b/cpp/include/idevice++/dvt/notifications.hpp new file mode 100644 index 0000000..c666ba0 --- /dev/null +++ b/cpp/include/idevice++/dvt/notifications.hpp @@ -0,0 +1,48 @@ +// Jackson Coxson + +#pragma once +#include +#include +#include +#include +#include + +namespace IdeviceFFI { + +using NotificationsPtr = + std::unique_ptr>; + +struct NotificationInfo { + std::string notification_type; + int64_t mach_absolute_time = 0; + std::string exec_name; + std::string app_name; + uint32_t pid = 0; + std::string state_description; +}; + +class Notifications { + public: + static Result create(RemoteServer& server); + + Result start(); + Result stop(); + Result next_notification(); + + ~Notifications() noexcept = default; + Notifications(Notifications&&) noexcept = default; + Notifications& operator=(Notifications&&) noexcept = default; + Notifications(const Notifications&) = delete; + Notifications& operator=(const Notifications&) = delete; + + NotificationsHandle* raw() const noexcept { return handle_.get(); } + static Notifications adopt(NotificationsHandle* h) noexcept { + return Notifications(h); + } + + private: + explicit Notifications(NotificationsHandle* h) noexcept : handle_(h) {} + NotificationsPtr handle_{}; +}; + +} // namespace IdeviceFFI diff --git a/cpp/sln/idevice++.vcxproj b/cpp/sln/idevice++.vcxproj index d5c8751..7249773 100644 --- a/cpp/sln/idevice++.vcxproj +++ b/cpp/sln/idevice++.vcxproj @@ -34,10 +34,18 @@ + + + + + + + + @@ -59,10 +67,18 @@ + + + + + + + + @@ -361,4 +377,4 @@ - \ No newline at end of file + diff --git a/cpp/sln/idevice++.vcxproj.filters b/cpp/sln/idevice++.vcxproj.filters index a5d824a..d2499be 100644 --- a/cpp/sln/idevice++.vcxproj.filters +++ b/cpp/sln/idevice++.vcxproj.filters @@ -24,6 +24,27 @@ Header Files\idevice++ + + Header Files\idevice++ + + + Header Files\idevice++ + + + Header Files\idevice++ + + + Header Files\idevice++ + + + Header Files\idevice++ + + + Header Files\idevice++ + + + Header Files\idevice++ + Header Files\idevice++ @@ -33,6 +54,9 @@ Header Files\idevice++ + + Header Files\idevice++ + Header Files\idevice++ @@ -146,6 +170,27 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + Source Files @@ -155,5 +200,8 @@ Source Files + + Source Files + - \ No newline at end of file + diff --git a/cpp/src/dvt/energy_monitor.cpp b/cpp/src/dvt/energy_monitor.cpp new file mode 100644 index 0000000..bc2e8cf --- /dev/null +++ b/cpp/src/dvt/energy_monitor.cpp @@ -0,0 +1,57 @@ +// Jackson Coxson + +#include + +namespace IdeviceFFI { + +Result EnergyMonitor::create(RemoteServer& server) { + EnergyMonitorHandle* out = nullptr; + FfiError e(::energy_monitor_new(server.raw(), &out)); + if (e) return Err(e); + return Ok(EnergyMonitor::adopt(out)); +} + +Result EnergyMonitor::start_sampling(const std::vector& pids) { + FfiError e(::energy_monitor_start_sampling( + handle_.get(), pids.empty() ? nullptr : pids.data(), pids.size())); + if (e) return Err(e); + return Ok(); +} + +Result EnergyMonitor::stop_sampling(const std::vector& pids) { + FfiError e(::energy_monitor_stop_sampling( + handle_.get(), pids.empty() ? nullptr : pids.data(), pids.size())); + if (e) return Err(e); + return Ok(); +} + +Result, FfiError> EnergyMonitor::sample_attributes( + const std::vector& pids) { + IdeviceEnergySample* raw = nullptr; + size_t count = 0; + FfiError e(::energy_monitor_sample_attributes( + handle_.get(), pids.empty() ? nullptr : pids.data(), pids.size(), &raw, &count)); + if (e) return Err(e); + + std::vector samples; + samples.reserve(count); + for (size_t i = 0; i < count; ++i) { + const auto& s = raw[i]; + samples.push_back({ + s.pid, + s.timestamp, + s.total_energy, + s.cpu_energy, + s.gpu_energy, + s.networking_energy, + s.display_energy, + s.location_energy, + s.appstate_energy, + }); + } + + ::energy_monitor_samples_free(raw, count); + return Ok(std::move(samples)); +} + +} // namespace IdeviceFFI diff --git a/cpp/src/dvt/graphics.cpp b/cpp/src/dvt/graphics.cpp new file mode 100644 index 0000000..9622735 --- /dev/null +++ b/cpp/src/dvt/graphics.cpp @@ -0,0 +1,47 @@ +// Jackson Coxson + +#include + +namespace IdeviceFFI { + +Result Graphics::create(RemoteServer& server) { + GraphicsHandle* out = nullptr; + FfiError e(::graphics_new(server.raw(), &out)); + if (e) return Err(e); + return Ok(Graphics::adopt(out)); +} + +Result Graphics::start(double interval) { + FfiError e(::graphics_start_sampling(handle_.get(), interval)); + if (e) return Err(e); + return Ok(); +} + +Result Graphics::stop() { + FfiError e(::graphics_stop_sampling(handle_.get())); + if (e) return Err(e); + return Ok(); +} + +Result Graphics::next_sample() { + IdeviceGraphicsSample* raw = nullptr; + FfiError e(::graphics_next_sample(handle_.get(), &raw)); + if (e) return Err(e); + + GraphicsSample sample{}; + if (raw) { + sample.timestamp = raw->timestamp; + sample.fps = raw->fps; + sample.alloc_system_memory = raw->alloc_system_memory; + sample.in_use_system_memory = raw->in_use_system_memory; + sample.in_use_system_memory_driver = raw->in_use_system_memory_driver; + sample.gpu_bundle_name = + raw->gpu_bundle_name ? std::string(raw->gpu_bundle_name) : std::string(); + sample.recovery_count = raw->recovery_count; + } + + ::graphics_sample_free(raw); + return Ok(std::move(sample)); +} + +} // namespace IdeviceFFI diff --git a/cpp/src/dvt/notifications.cpp b/cpp/src/dvt/notifications.cpp new file mode 100644 index 0000000..504f2ae --- /dev/null +++ b/cpp/src/dvt/notifications.cpp @@ -0,0 +1,47 @@ +// Jackson Coxson + +#include + +namespace IdeviceFFI { + +Result Notifications::create(RemoteServer& server) { + NotificationsHandle* out = nullptr; + FfiError e(::notifications_new(server.raw(), &out)); + if (e) return Err(e); + return Ok(Notifications::adopt(out)); +} + +Result Notifications::start() { + FfiError e(::notifications_start(handle_.get())); + if (e) return Err(e); + return Ok(); +} + +Result Notifications::stop() { + FfiError e(::notifications_stop(handle_.get())); + if (e) return Err(e); + return Ok(); +} + +Result Notifications::next_notification() { + IdeviceNotificationInfo* raw = nullptr; + FfiError e(::notifications_get_next(handle_.get(), &raw)); + if (e) return Err(e); + + NotificationInfo info{}; + if (raw) { + info.notification_type = + raw->notification_type ? std::string(raw->notification_type) : std::string(); + info.mach_absolute_time = raw->mach_absolute_time; + info.exec_name = raw->exec_name ? std::string(raw->exec_name) : std::string(); + info.app_name = raw->app_name ? std::string(raw->app_name) : std::string(); + info.pid = raw->pid; + info.state_description = + raw->state_description ? std::string(raw->state_description) : std::string(); + } + + ::notifications_info_free(raw); + return Ok(std::move(info)); +} + +} // namespace IdeviceFFI