Android/App개발2011.02.22 21:42


open_src/system/core/adb가 윈도우용으로 빌드될 때 아래의 소스들이 컴파일된다.
 usb_windows.c
 get_my_path_windows.c
 adb.c 
 console.c 
 transport.c 
 transport_local.c 
 transport_usb.c 
 commandline.c 
 adb_client.c 
 sockets.c 
 services.c 
 file_sync_client.c 
 shlist.c 
 utils.c 
 usb_vendors.c

아래 위치의 헤더파일들이 참조된다.
development/host/windows/usb/api/

프로그램의 시작지점은 아래와 같다.

int main(int argc, char **argv)
{
    adb_trace_init();
#if ADB_HOST
    adb_sysdeps_init();
    return adb_commandline(argc - 1, argv + 1);
#else
    if((argc > 1) && (!strcmp(argv[1],"recovery"))) {
        adb_device_banner = "recovery";
        recovery_mode = 1;
    }

    start_device_log();
    return adb_main(0);
#endif
}

commandline.c의 아래 함수에 커맨드라인 명령어의 처리 코드를 찾아볼 수 있다.

int adb_commandline(int argc, char **argv)
{
...
}

신고
Posted by 삼스
Android/App개발2011.02.22 21:15


adb윈도우용은 AdbWinApi.dll과 AdbWinUsbApi.dll과 함께 연동된다.
주요 API는 AdbWinApi.dll에 정의되어 있으며 AdbWinUsbApi.dll은 실제 Usb device와 연동부분을 책임진다.

오픈소스상의 아래 위치에 소스가 위치한다.

open_src/system/core/adb -> adb server, adb demon, adb client based on command-line의 소스가 OS별(linux, window, OSX)로 구현되어 있다.
open_src/developments/hosts/windows/usb -> 윈도우용 AdbWinApi.dll과 AdbWinUsbApi.dll의 소스와 드라이버등이 있다.

developments/hosts/windows/usb폴더구조는 다음과 같다.
 adb_winapi_test : test app
 api                   : AdbWinApi의 소스, adb.exe가 직접적으로 사용한다.
 legacy              : 드라이버
 winusb             : AdbWinUsbApi의 소스, Usb 연동부분에 대한 소스로 AdbWinApi가 로드하여 사용한다.

adb와 유사한 클라이언트 앱을 만들고자 한다면 AdbWinApi.dll이 노출하는 API들에 대한 스펙을 숙지하는것이 중요하다.
아래에 몇가지 API들을 소개한다.

adb_api.h
ADBWIN_API ADBAPIHANDLE __cdecl AdbEnumInterfaces(GUID class_id,
                                          bool exclude_not_present,
                                          bool exclude_removed,
                                          bool active_only);

ADBWIN_API bool __cdecl AdbNextInterface(ADBAPIHANDLE adb_handle,
                                 AdbInterfaceInfo* info,
                                 unsigned long* size);

ADBWIN_API bool __cdecl AdbResetInterfaceEnum(ADBAPIHANDLE adb_handle);

ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterfaceByName(const wchar_t* interface_name);

ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterface(GUID class_id,
                                           unsigned short vendor_id,
                                           unsigned short product_id,
                                           unsigned char interface_id);

ADBWIN_API bool __cdecl AdbGetInterfaceName(ADBAPIHANDLE adb_interface,
                                    void* buffer,
                                    unsigned long* buffer_char_size,
                                    bool ansi);

ADBWIN_API bool __cdecl AdbGetSerialNumber(ADBAPIHANDLE adb_interface,
                                   void* buffer,
                                   unsigned long* buffer_char_size,
                                   bool ansi);

ADBWIN_API bool __cdecl AdbGetUsbDeviceDescriptor(ADBAPIHANDLE adb_interface,
                                          USB_DEVICE_DESCRIPTOR* desc);

ADBWIN_API bool __cdecl AdbGetUsbConfigurationDescriptor(
                    ADBAPIHANDLE adb_interface,
                    USB_CONFIGURATION_DESCRIPTOR* desc);

ADBWIN_API bool __cdecl AdbGetUsbInterfaceDescriptor(ADBAPIHANDLE adb_interface,
                                             USB_INTERFACE_DESCRIPTOR* desc);

ADBWIN_API bool __cdecl AdbGetEndpointInformation(ADBAPIHANDLE adb_interface,
                                          unsigned char endpoint_index,
                                          AdbEndpointInformation* info);

ADBWIN_API bool __cdecl AdbGetDefaultBulkReadEndpointInformation(
                    ADBAPIHANDLE adb_interface,
                    AdbEndpointInformation* info);

ADBWIN_API bool __cdecl AdbGetDefaultBulkWriteEndpointInformation(
                    ADBAPIHANDLE adb_interface,
                    AdbEndpointInformation* info);

ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenEndpoint(ADBAPIHANDLE adb_interface,
                                        unsigned char endpoint_index,
                                        AdbOpenAccessType access_type,
                                        AdbOpenSharingMode sharing_mode);

ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkReadEndpoint(
                            ADBAPIHANDLE adb_interface,
                            AdbOpenAccessType access_type,
                            AdbOpenSharingMode sharing_mode);

ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkWriteEndpoint(
                            ADBAPIHANDLE adb_interface,
                            AdbOpenAccessType access_type,
                            AdbOpenSharingMode sharing_mode);

ADBWIN_API ADBAPIHANDLE __cdecl AdbGetEndpointInterface(ADBAPIHANDLE adb_endpoint);

ADBWIN_API bool __cdecl AdbQueryInformationEndpoint(ADBAPIHANDLE adb_endpoint,
                                            AdbEndpointInformation* info);

ADBWIN_API ADBAPIHANDLE __cdecl AdbReadEndpointAsync(ADBAPIHANDLE adb_endpoint,
                                             void* buffer,
                                             unsigned long bytes_to_read,
                                             unsigned long* bytes_read,
                                             unsigned long time_out,
                                             HANDLE event_handle);

ADBWIN_API ADBAPIHANDLE __cdecl AdbWriteEndpointAsync(ADBAPIHANDLE adb_endpoint,
                                              void* buffer,
                                              unsigned long bytes_to_write,
                                              unsigned long* bytes_written,
                                              unsigned long time_out,
                                              HANDLE event_handle);

ADBWIN_API bool __cdecl AdbReadEndpointSync(ADBAPIHANDLE adb_endpoint,
                                    void* buffer,
                                    unsigned long bytes_to_read,
                                    unsigned long* bytes_read,
                                    unsigned long time_out);

ADBWIN_API bool __cdecl AdbWriteEndpointSync(ADBAPIHANDLE adb_endpoint,
                                     void* buffer,
                                     unsigned long bytes_to_write,
                                     unsigned long* bytes_written,
                                     unsigned long time_out);

ADBWIN_API bool __cdecl AdbGetOvelappedIoResult(ADBAPIHANDLE adb_io_completion,
                                        LPOVERLAPPED overlapped,
                                        unsigned long* bytes_transferred,
                                        bool wait);

ADBWIN_API bool __cdecl AdbHasOvelappedIoComplated(ADBAPIHANDLE adb_io_completion);


ADBWIN_API bool __cdecl AdbCloseHandle(ADBAPIHANDLE adb_handle);

신고
Posted by 삼스
Android/정리2010.01.14 13:00
1. ENG모드로 빌드하면 됨.
2. initramfs의 default.prop파일의 secure값이랑 adb값, debuggable값을 각각 0,1,1로 setting한 걸로 바꾸면 됨.
신고
Posted by 삼스
Android/정리2010.01.06 23:01
http://learnandroid.blogspot.com/2008/01/run-android-application-from-command.html

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.iftitah.android.contact">
  <application android:icon="@drawable/icon">
   <activity class=".Contact" android:label="@string/app_name">
    <intent-filter>
    <action android:value="android.intent.action.MAIN" />
    <category android:value="android.intent.category.LAUNCHER" />
   </intent-filter>
  </activity>
 </application>
.
.
</manifest>

위와 같이 activity가 정의되어 있을 때... 아래와 같이 실행하면 됨

am start -a android.intent.action.MAIN -n
com.iftitah.android.contact/com.iftitah.android.contact.Contact
신고
Posted by 삼스

티스토리 툴바