Switch minadb over to C++.
Change-Id: I5afaf70caa590525627c676c88b445d3162de33e
This commit is contained in:
parent
23017c5d5c
commit
20531ef605
9 changed files with 24 additions and 31 deletions
|
@ -30,10 +30,8 @@
|
||||||
#include "install.h"
|
#include "install.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "adb_install.h"
|
#include "adb_install.h"
|
||||||
extern "C" {
|
|
||||||
#include "minadbd/fuse_adb_provider.h"
|
#include "minadbd/fuse_adb_provider.h"
|
||||||
#include "fuse_sideload.h"
|
#include "fuse_sideload.h"
|
||||||
}
|
|
||||||
|
|
||||||
static RecoveryUI* ui = NULL;
|
static RecoveryUI* ui = NULL;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,13 @@
|
||||||
#ifndef __FUSE_SDCARD_PROVIDER_H
|
#ifndef __FUSE_SDCARD_PROVIDER_H
|
||||||
#define __FUSE_SDCARD_PROVIDER_H
|
#define __FUSE_SDCARD_PROVIDER_H
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
void* start_sdcard_fuse(const char* path);
|
void* start_sdcard_fuse(const char* path);
|
||||||
void finish_sdcard_fuse(void* token);
|
void finish_sdcard_fuse(void* token);
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
#ifndef __FUSE_SIDELOAD_H
|
#ifndef __FUSE_SIDELOAD_H
|
||||||
#define __FUSE_SIDELOAD_H
|
#define __FUSE_SIDELOAD_H
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
// define the filenames created by the sideload FUSE filesystem
|
// define the filenames created by the sideload FUSE filesystem
|
||||||
#define FUSE_SIDELOAD_HOST_MOUNTPOINT "/sideload"
|
#define FUSE_SIDELOAD_HOST_MOUNTPOINT "/sideload"
|
||||||
#define FUSE_SIDELOAD_HOST_FILENAME "package.zip"
|
#define FUSE_SIDELOAD_HOST_FILENAME "package.zip"
|
||||||
|
@ -35,4 +39,6 @@ struct provider_vtab {
|
||||||
int run_fuse_sideload(struct provider_vtab* vtab, void* cookie,
|
int run_fuse_sideload(struct provider_vtab* vtab, void* cookie,
|
||||||
uint64_t file_size, uint32_t block_size);
|
uint64_t file_size, uint32_t block_size);
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,9 +11,9 @@ minadbd_cflags := \
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
adb_main.c \
|
adb_main.cpp \
|
||||||
fuse_adb_provider.c \
|
fuse_adb_provider.cpp \
|
||||||
services.c \
|
services.cpp \
|
||||||
|
|
||||||
LOCAL_MODULE := libminadbd
|
LOCAL_MODULE := libminadbd
|
||||||
LOCAL_CFLAGS := $(minadbd_cflags)
|
LOCAL_CFLAGS := $(minadbd_cflags)
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct adb_data {
|
struct adb_data {
|
||||||
int sfd; // file descriptor for the adb channel
|
int sfd; // file descriptor for the adb channel
|
||||||
|
|
||||||
|
@ -30,12 +26,7 @@ struct adb_data {
|
||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer,
|
int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer, uint32_t fetch_size);
|
||||||
uint32_t fetch_size);
|
|
||||||
int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size);
|
int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,19 +36,16 @@ struct stinfo {
|
||||||
void *cookie;
|
void *cookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void* service_bootstrap_func(void* x) {
|
||||||
void *service_bootstrap_func(void *x)
|
stinfo* sti = reinterpret_cast<stinfo*>(x);
|
||||||
{
|
|
||||||
stinfo *sti = x;
|
|
||||||
sti->func(sti->fd, sti->cookie);
|
sti->func(sti->fd, sti->cookie);
|
||||||
free(sti);
|
free(sti);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sideload_host_service(int sfd, void* cookie)
|
static void sideload_host_service(int sfd, void* cookie) {
|
||||||
{
|
|
||||||
char* saveptr;
|
char* saveptr;
|
||||||
const char* s = adb_strtok_r(cookie, ":", &saveptr);
|
const char* s = adb_strtok_r(reinterpret_cast<char*>(cookie), ":", &saveptr);
|
||||||
uint64_t file_size = strtoull(s, NULL, 10);
|
uint64_t file_size = strtoull(s, NULL, 10);
|
||||||
s = adb_strtok_r(NULL, ":", &saveptr);
|
s = adb_strtok_r(NULL, ":", &saveptr);
|
||||||
uint32_t block_size = strtoul(s, NULL, 10);
|
uint32_t block_size = strtoul(s, NULL, 10);
|
||||||
|
@ -65,22 +62,20 @@ static void sideload_host_service(int sfd, void* cookie)
|
||||||
|
|
||||||
static int create_service_thread(void (*func)(int, void *), void *cookie)
|
static int create_service_thread(void (*func)(int, void *), void *cookie)
|
||||||
{
|
{
|
||||||
stinfo *sti;
|
|
||||||
adb_thread_t t;
|
|
||||||
int s[2];
|
int s[2];
|
||||||
|
|
||||||
if(adb_socketpair(s)) {
|
if(adb_socketpair(s)) {
|
||||||
printf("cannot create service socket pair\n");
|
printf("cannot create service socket pair\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sti = malloc(sizeof(stinfo));
|
stinfo* sti = reinterpret_cast<stinfo*>(malloc(sizeof(stinfo)));
|
||||||
if(sti == 0) fatal("cannot allocate stinfo");
|
if(sti == 0) fatal("cannot allocate stinfo");
|
||||||
sti->func = func;
|
sti->func = func;
|
||||||
sti->cookie = cookie;
|
sti->cookie = cookie;
|
||||||
sti->fd = s[1];
|
sti->fd = s[1];
|
||||||
|
|
||||||
if(adb_thread_create( &t, service_bootstrap_func, sti)){
|
adb_thread_t t;
|
||||||
|
if (adb_thread_create( &t, service_bootstrap_func, sti)){
|
||||||
free(sti);
|
free(sti);
|
||||||
adb_close(s[0]);
|
adb_close(s[0]);
|
||||||
adb_close(s[1]);
|
adb_close(s[1]);
|
||||||
|
@ -92,8 +87,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
|
||||||
return s[0];
|
return s[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int service_to_fd(const char *name)
|
int service_to_fd(const char* name) {
|
||||||
{
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!strncmp(name, "sideload:", 9)) {
|
if (!strncmp(name, "sideload:", 9)) {
|
|
@ -43,11 +43,9 @@
|
||||||
#include "screen_ui.h"
|
#include "screen_ui.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "adb_install.h"
|
#include "adb_install.h"
|
||||||
extern "C" {
|
|
||||||
#include "adb.h"
|
#include "adb.h"
|
||||||
#include "fuse_sideload.h"
|
#include "fuse_sideload.h"
|
||||||
#include "fuse_sdcard_provider.h"
|
#include "fuse_sdcard_provider.h"
|
||||||
}
|
|
||||||
|
|
||||||
struct selabel_handle *sehandle;
|
struct selabel_handle *sehandle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue