代码拉取完成,页面将自动刷新
#ifndef _CADB_CLIENT_H_
#define _CADB_CLIENT_H_
#include <string>
#include <vector>
#include <stdint.h>
using std::string;
//#ifdef WIN32
//#ifdef ADBAPI_EXPORTS
//#define ADBAPI __declspec(dllexport)
//#else
//#define ADBAPI __declspec(dllimport)
//#endif
//#endif
#ifndef ADBAPI
#define ADBAPI
#endif
typedef int(*shell_exec_callback)(const char* data, int len, void* ptr);
typedef int(*process_callback)(uint64_t totalbytes, uint64_t size, void* ptr);
class ADBAPI AdbClient
{
public:
AdbClient();
~AdbClient();
enum transport_type {
kTransportUsb,
kTransportLocal,
kTransportAny,
kTransportHost,
} ;
static void initLib();
//启动服务器
int start_server();
int kill_server();
//传文件
int push(const char *lpath, const char *rpath,process_callback callback,void* ptr);
int pull(const char *lpath,const char *rpath,process_callback callback, void* ptr);
const char* serial() { return m_adb_serial.c_str(); }
/* connect to adb, connect to the named service, and return
** a valid fd for interacting with that service upon success
** or a negative number on failure
*/
int connect(const char *service);
int read(int fd,char* data,int len);
int write(int fd, const char* data,int len);
//读写成功才返回
int readx(int fd, char* data, int len);
int writex(int fd, const char* data, int len);
int close(int fd);
/* connect to adb, connect to the named service, return 0 if
** the connection succeeded AND the service returned OKAY
*/
int command(const char *service);
//执行shell命令
//shell:ime list -a
int shell_exec(const char *service, shell_exec_callback callback,void* ptr);
int shell_exec(const char *service,std::string* out);
/* connect to adb, connect to the named service, return
** a malloc'd string of its response upon success or NULL
** on failure.
*/
//host:devices
char *query(const char *service);
/* Set the preferred transport to connect to.
*/
void set_transport(transport_type type, const char* serial);
/* Set TCP specifics of the transport to use
*/
void set_tcp_specifics(int server_port);
/* Set TCP Hostname of the transport to use
*/
void set_tcp_name(const char* hostname);
/* Return the console port of the currently connected emulator (if any)
* of -1 if there is no emulator, and -2 if there is more than one.
* assumes adb_set_transport() was alled previously...
*/
int get_emulator_console_port(void);
/* send commands to the current emulator instance. will fail if there
* is zero, or more than one emulator connected (or if you use -s <serial>
* with a <serial> that does not designate an emulator)
*/
int send_emulator_command(int argc, char** argv);
/* return verbose error string from last operation */
const char *error(void);
/* read a standard adb status response (OKAY|FAIL) and
** return 0 in the event of OKAY, -1 in the event of FAIL
** or protocol error
*/
int status(int fd);
int device_list(std::vector<std::string>* vector);
//截屏保持为png文件
bool capture(const char* file);
std::string get_abi();//x86,armeabi-v7a ...
std::string get_sdk_version();//sdk版本号
//运行截图需要在子线程里执行,否则会阻塞
bool run_mini_cap(const char* commend, shell_exec_callback callback, void* ptr);
bool run_mini_touch(shell_exec_callback callback, void* ptr);
//判断手机是否锁定
int is_phone_locked(bool* isScreenOff,bool* isLock);
int unlock_phone();
int forward(const char* local,const char* remote);
int get_screen_size(int* w,int* h);
int delete_file(char* filename);
//安装apk
int install(const char* file, process_callback callback, void* ptr);
int uninstall(const char* pkgName);
private:
int _connect(const char *service);
int switch_socket_transport(int fd);
transport_type m_adb_transport;
int m_adb_server_port;
std::string m_adb_serial;
std::string m_adb_server_name;
char m_adb_error[256];
};
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。