mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-05-17 20:20:34 +00:00
feat(dvt): wrappers for graphics, notifications, and energy monitor (#91)
also updates to include all dvt wrappers that werent mentioned
This commit is contained in:
@@ -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 = "<group>"; };
|
||||
396C56B22EA7F53000188F4B /* condition_inducer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = condition_inducer.cpp; sourceTree = "<group>"; };
|
||||
396C56B32EA7F53000188F4B /* device_info.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = device_info.cpp; sourceTree = "<group>"; };
|
||||
296C56B12EA7F53000188F4B /* energy_monitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = energy_monitor.cpp; sourceTree = "<group>"; };
|
||||
196C56B32EA7F53000188F4B /* graphics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = graphics.cpp; sourceTree = "<group>"; };
|
||||
196C56B42EA7F53000188F4B /* location_simulation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = location_simulation.cpp; sourceTree = "<group>"; };
|
||||
396C56B42EA7F53000188F4B /* network_monitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = network_monitor.cpp; sourceTree = "<group>"; };
|
||||
196C56B22EA7F53000188F4B /* notifications.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = notifications.cpp; sourceTree = "<group>"; };
|
||||
196C56B52EA7F53000188F4B /* process_control.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = process_control.cpp; sourceTree = "<group>"; };
|
||||
196C56B62EA7F53000188F4B /* remote_server.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = remote_server.cpp; sourceTree = "<group>"; };
|
||||
196C56B72EA7F53000188F4B /* screenshot.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = screenshot.cpp; sourceTree = "<group>"; };
|
||||
396C56B52EA7F53000188F4B /* sysmontap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sysmontap.cpp; sourceTree = "<group>"; };
|
||||
196C56B92EA7F53000188F4B /* adapter_stream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = adapter_stream.cpp; sourceTree = "<group>"; };
|
||||
196C56BA2EA7F53000188F4B /* app_service.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = app_service.cpp; sourceTree = "<group>"; };
|
||||
196C56BB2EA7F53000188F4B /* core_device.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = core_device.cpp; sourceTree = "<group>"; };
|
||||
@@ -76,10 +100,18 @@
|
||||
196C56C62EA7F53000188F4B /* rsd.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = rsd.cpp; sourceTree = "<group>"; };
|
||||
196C56C72EA7F53000188F4B /* tcp_callback_feeder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = tcp_callback_feeder.cpp; sourceTree = "<group>"; };
|
||||
196C56C82EA7F53000188F4B /* usbmuxd.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = usbmuxd.cpp; sourceTree = "<group>"; };
|
||||
396C56D12EA7F54900188F4B /* application_listing.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = application_listing.hpp; sourceTree = "<group>"; };
|
||||
396C56D22EA7F54900188F4B /* condition_inducer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = condition_inducer.hpp; sourceTree = "<group>"; };
|
||||
396C56D32EA7F54900188F4B /* device_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = device_info.hpp; sourceTree = "<group>"; };
|
||||
296C56DB2EA7F54900188F4B /* energy_monitor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = energy_monitor.hpp; sourceTree = "<group>"; };
|
||||
196C56DD2EA7F54900188F4B /* graphics.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = graphics.hpp; sourceTree = "<group>"; };
|
||||
196C56DE2EA7F54900188F4B /* location_simulation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = location_simulation.hpp; sourceTree = "<group>"; };
|
||||
396C56D42EA7F54900188F4B /* network_monitor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = network_monitor.hpp; sourceTree = "<group>"; };
|
||||
196C56DC2EA7F54900188F4B /* notifications.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = notifications.hpp; sourceTree = "<group>"; };
|
||||
196C56DF2EA7F54900188F4B /* process_control.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = process_control.hpp; sourceTree = "<group>"; };
|
||||
196C56E02EA7F54900188F4B /* remote_server.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = remote_server.hpp; sourceTree = "<group>"; };
|
||||
196C56E12EA7F54900188F4B /* screenshot.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = screenshot.hpp; sourceTree = "<group>"; };
|
||||
396C56D52EA7F54900188F4B /* sysmontap.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = sysmontap.hpp; sourceTree = "<group>"; };
|
||||
196C56E32EA7F54900188F4B /* adapter_stream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = adapter_stream.hpp; sourceTree = "<group>"; };
|
||||
196C56E42EA7F54900188F4B /* app_service.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = app_service.hpp; sourceTree = "<group>"; };
|
||||
196C56E52EA7F54900188F4B /* bindings.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = bindings.hpp; sourceTree = "<group>"; };
|
||||
@@ -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 = "<group>";
|
||||
@@ -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 = "<group>";
|
||||
@@ -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 */,
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#pragma once
|
||||
#include <idevice++/bindings.hpp>
|
||||
#include <idevice++/dvt/remote_server.hpp>
|
||||
#include <idevice++/result.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
using EnergyMonitorPtr =
|
||||
std::unique_ptr<EnergyMonitorHandle,
|
||||
FnDeleter<EnergyMonitorHandle, energy_monitor_free>>;
|
||||
|
||||
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<EnergyMonitor, FfiError> create(RemoteServer& server);
|
||||
|
||||
Result<void, FfiError> start_sampling(const std::vector<uint32_t>& pids);
|
||||
Result<void, FfiError> stop_sampling(const std::vector<uint32_t>& pids);
|
||||
Result<std::vector<EnergySample>, FfiError> sample_attributes(
|
||||
const std::vector<uint32_t>& 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
|
||||
@@ -0,0 +1,47 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#pragma once
|
||||
#include <idevice++/bindings.hpp>
|
||||
#include <idevice++/dvt/remote_server.hpp>
|
||||
#include <idevice++/result.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
using GraphicsPtr =
|
||||
std::unique_ptr<GraphicsHandle, FnDeleter<GraphicsHandle, graphics_free>>;
|
||||
|
||||
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<Graphics, FfiError> create(RemoteServer& server);
|
||||
|
||||
Result<void, FfiError> start(double interval);
|
||||
Result<void, FfiError> stop();
|
||||
Result<GraphicsSample, FfiError> 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
|
||||
@@ -0,0 +1,48 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#pragma once
|
||||
#include <idevice++/bindings.hpp>
|
||||
#include <idevice++/dvt/remote_server.hpp>
|
||||
#include <idevice++/result.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
using NotificationsPtr =
|
||||
std::unique_ptr<NotificationsHandle, FnDeleter<NotificationsHandle, notifications_free>>;
|
||||
|
||||
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<Notifications, FfiError> create(RemoteServer& server);
|
||||
|
||||
Result<void, FfiError> start();
|
||||
Result<void, FfiError> stop();
|
||||
Result<NotificationInfo, FfiError> 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
|
||||
@@ -34,10 +34,18 @@
|
||||
<ClInclude Include="..\include\idevice++\core_device_proxy.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\debug_proxy.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\diagnosticsservice.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\application_listing.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\condition_inducer.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\device_info.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\energy_monitor.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\graphics.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\location_simulation.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\network_monitor.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\notifications.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\process_control.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\remote_server.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\screenshot.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\dvt\sysmontap.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\ffi.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\heartbeat.hpp" />
|
||||
<ClInclude Include="..\include\idevice++\idevice.hpp" />
|
||||
@@ -59,10 +67,18 @@
|
||||
<ClCompile Include="..\src\core_device.cpp" />
|
||||
<ClCompile Include="..\src\debug_proxy.cpp" />
|
||||
<ClCompile Include="..\src\diagnosticsservice.cpp" />
|
||||
<ClCompile Include="..\src\dvt\application_listing.cpp" />
|
||||
<ClCompile Include="..\src\dvt\condition_inducer.cpp" />
|
||||
<ClCompile Include="..\src\dvt\device_info.cpp" />
|
||||
<ClCompile Include="..\src\dvt\energy_monitor.cpp" />
|
||||
<ClCompile Include="..\src\dvt\graphics.cpp" />
|
||||
<ClCompile Include="..\src\dvt\location_simulation.cpp" />
|
||||
<ClCompile Include="..\src\dvt\network_monitor.cpp" />
|
||||
<ClCompile Include="..\src\dvt\notifications.cpp" />
|
||||
<ClCompile Include="..\src\dvt\process_control.cpp" />
|
||||
<ClCompile Include="..\src\dvt\remote_server.cpp" />
|
||||
<ClCompile Include="..\src\dvt\screenshot.cpp" />
|
||||
<ClCompile Include="..\src\dvt\sysmontap.cpp" />
|
||||
<ClCompile Include="..\src\ffi.cpp" />
|
||||
<ClCompile Include="..\src\heartbeat.cpp" />
|
||||
<ClCompile Include="..\src\idevice.cpp" />
|
||||
|
||||
@@ -24,6 +24,27 @@
|
||||
<ClInclude Include="..\include\idevice++\dvt\location_simulation.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\application_listing.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\condition_inducer.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\device_info.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\energy_monitor.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\graphics.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\network_monitor.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\notifications.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\process_control.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
@@ -33,6 +54,9 @@
|
||||
<ClInclude Include="..\include\idevice++\dvt\screenshot.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\dvt\sysmontap.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\idevice++\adapter_stream.hpp">
|
||||
<Filter>Header Files\idevice++</Filter>
|
||||
</ClInclude>
|
||||
@@ -146,6 +170,27 @@
|
||||
<ClCompile Include="..\src\dvt\location_simulation.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\application_listing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\condition_inducer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\device_info.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\energy_monitor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\graphics.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\network_monitor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\notifications.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\process_control.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -155,5 +200,8 @@
|
||||
<ClCompile Include="..\src\dvt\screenshot.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\dvt\sysmontap.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,57 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/dvt/energy_monitor.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
Result<EnergyMonitor, FfiError> 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<void, FfiError> EnergyMonitor::start_sampling(const std::vector<uint32_t>& pids) {
|
||||
FfiError e(::energy_monitor_start_sampling(
|
||||
handle_.get(), pids.empty() ? nullptr : pids.data(), pids.size()));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<void, FfiError> EnergyMonitor::stop_sampling(const std::vector<uint32_t>& pids) {
|
||||
FfiError e(::energy_monitor_stop_sampling(
|
||||
handle_.get(), pids.empty() ? nullptr : pids.data(), pids.size()));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<std::vector<EnergySample>, FfiError> EnergyMonitor::sample_attributes(
|
||||
const std::vector<uint32_t>& 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<EnergySample> 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
|
||||
@@ -0,0 +1,47 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/dvt/graphics.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
Result<Graphics, FfiError> 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<void, FfiError> Graphics::start(double interval) {
|
||||
FfiError e(::graphics_start_sampling(handle_.get(), interval));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<void, FfiError> Graphics::stop() {
|
||||
FfiError e(::graphics_stop_sampling(handle_.get()));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<GraphicsSample, FfiError> 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
|
||||
@@ -0,0 +1,47 @@
|
||||
// Jackson Coxson
|
||||
|
||||
#include <idevice++/dvt/notifications.hpp>
|
||||
|
||||
namespace IdeviceFFI {
|
||||
|
||||
Result<Notifications, FfiError> 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<void, FfiError> Notifications::start() {
|
||||
FfiError e(::notifications_start(handle_.get()));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<void, FfiError> Notifications::stop() {
|
||||
FfiError e(::notifications_stop(handle_.get()));
|
||||
if (e) return Err(e);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<NotificationInfo, FfiError> 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
|
||||
Reference in New Issue
Block a user