123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- #pragma once
- #include <CrossPlatformDefine/PlatformDef.h>
- #include <CrossPlatformDefine/XErrorCode.h>
- #include <memory>
- #ifdef XPHONE_STATIC
- #define XPHONEDLL_API
- #else
- #ifdef XPHONEDLL_EXPORTS
- #define XPHONEDLL_API __declspec(dllexport)
- #else
- #define XPHONEDLL_API __declspec(dllimport)
- #endif // XPHONEDLL_EXPORTS
- #endif // XPHONE_STATIC
- enum XConnectMode
- {
- XConnectMode_USB,
- XConnectMode_WIFI
- };
- enum XDeviceChange
- {
- XDeviceChange_Unknow = 0,
- XDeviceChange_Add = 1,
- XDeviceChange_Remove = 2,
- };
- struct XDeviceInfo
- {
- XString szIdentify;
- XString szDeviceName;
- XString szResolution;
- XString szBrand;
- XString szIMEI;
- XString szModel;
- };
- //屏幕回显的回掉
- class IXPhoneScreenShow
- {
- public:
- //回掉屏幕的数据,一个完整的PNG 图像,包括PNG 头
- virtual void OnScreenShow(const byte* buffer, int iBufferLen) = 0;
- };
- //手机端发过来的主动TCP 信息
- class IXPhoneCommonRecvMsg
- {
- public:
- virtual void OnRecvTcpMsg(const XString& strDeviceIdentify, const byte* buffer, int iBufferLen) = 0;
- virtual void OnCommonDisconnect(const XString& strDeviceIdentify) = 0;
- };
- class IXPhoneDevice
- {
- public:
- virtual ~IXPhoneDevice();
- //获取设备唯一标识符
- virtual XString GetIdentify() = 0;//获取设备唯一标识
- virtual XConnectMode GetConnectMode() = 0;//获取连接模式
- //0 正常模式 1 简易模式
- virtual XErrorcode ConnectToDevice() = 0;//链接设备
- virtual XErrorcode DisConnectDevice() = 0;//断开设备连接
- virtual XErrorcode GetDeviceInfo(XDeviceInfo& deviceInfo, bool bStartCapture) = 0;//获取设备信息
- //设置屏幕回显回掉
- virtual XErrorcode SetScreenShowCallback(IXPhoneScreenShow* pCallback) = 0;
- //设备操作
- virtual XErrorcode RestartDevice() = 0;//重启设备
- virtual XErrorcode ExecuteHomeCommand() = 0;//模拟按下手机的HOME 按键
- virtual XErrorcode ExecuteBackCommand() = 0;//模拟按下手机的Back 按键
- virtual XErrorcode ExecuteMenuCommand() = 0;//模拟按下手机的Menu 按键
- //提供一个adb 命令
- virtual XErrorcode ExecuteAdbCommand(const XString&strAdbCommand, XString& strResult) = 0;
- //安装应用接口
- virtual XErrorcode InstallApp(const XString &strSrcPath) = 0;
- virtual XErrorcode UnInstallApp(const XString &strPackageName) = 0;
- //屏幕触摸接口
- virtual XErrorcode ScreenTouchDown(int x, int y) = 0;
- virtual XErrorcode ScreenTouchUp(int x, int y) = 0;
- virtual XErrorcode ScreenTouchMove(int x, int y) = 0;
- //脚本录制
- virtual XErrorcode StartRecord() = 0;
- virtual XErrorcode StopRecord(const XString& strSavePath) = 0;
- virtual XErrorcode PlayRecord(const XString& strSavepath,bool* pbStop) = 0;
- //文本输入
- virtual XErrorcode InputText(const XString& strText) = 0;
- virtual XErrorcode SwitchIME() = 0;
- virtual XErrorcode ExecuteDelCommand() =0;
- //普通TCP 消息回掉
- virtual XErrorcode SetCommonTcpMsgCallback(IXPhoneCommonRecvMsg* pCallback) = 0;
- virtual XErrorcode SendCommonTcpMSG(const byte* buffer, int iBufferLen) = 0;
- //切换到前台
- virtual XErrorcode SwitchForground() = 0;
- };
- class IXPhoneDeviceEvent
- {
- public:
- virtual void XPhoneDeviceChanged(
- /* [in] */ std::shared_ptr<IXPhoneDevice> pXPhoneDevice,
- /* [in] */ enum XDeviceChange changeType) = 0;
- };
- //所有监视器基类
- class XPHONEDLL_API IXPhoneMonitorAddin
- {
- public:
- virtual ~IXPhoneMonitorAddin();
- //初始化
- virtual XErrorcode Init(IXPhoneDeviceEvent* pXPhoneEvent) = 0;
- //反初始化
- virtual void UnInit() = 0;
- //开始监听
- virtual XErrorcode StartListen( void) = 0;
-
- virtual XErrorcode GetWifiConnectParam(std::string& strIP, int& iPort)=0;
- static IXPhoneMonitorAddin* CreateInstance();
- static void DestroyInstance(IXPhoneMonitorAddin* pInstance);
- //提供一个静态函数,用来执行adb 命令
- static XString ExecuteAdbCommand(const XString& strCommand);
- };
|