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 삼스

댓글을 달아 주세요

  1. 사람들은 죽을걸 알면서도 살잖아 .사랑은 원래 유치한거에요

    2013.07.11 04:04 [ ADDR : EDIT/ DEL : REPLY ]
  2. 창밖을 봐 바람에 나뭇가지가 살며시 흔들리면 네가 사랑하는 사람이 널 사랑하고 있는거야.

    2013.07.14 07:51 [ ADDR : EDIT/ DEL : REPLY ]
  3. 당신 매력있어, 자기가 얼마나 매력있는지 모르는게 당신매력이야

    2013.07.14 09:54 [ ADDR : EDIT/ DEL : REPLY ]

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 삼스

댓글을 달아 주세요

  1. 비밀댓글입니다

    2011.04.15 22:52 [ ADDR : EDIT/ DEL : REPLY ]
  2. 눈을 감아봐 입가에 미소가 떠오르면 네가 사랑하는 그 사람이 널 사랑하고 있는거야.

    2013.07.11 07:35 [ ADDR : EDIT/ DEL : REPLY ]

Android/정리2010.01.14 13:00
1. ENG모드로 빌드하면 됨.
2. initramfs의 default.prop파일의 secure값이랑 adb값, debuggable값을 각각 0,1,1로 setting한 걸로 바꾸면 됨.
Posted by 삼스

댓글을 달아 주세요

  1. 당신은 내가사랑할 만한 사람이 아니예요,사랑하지 않으면 안될 사람이예요.

    2013.07.15 01:28 [ ADDR : EDIT/ DEL : REPLY ]
  2. 창밖을 봐 바람에 나뭇가지가 살며시 흔들리면 네가 사랑하는 사람이 널 사랑하고 있는거야.

    2013.07.17 11:31 [ ADDR : EDIT/ DEL : REPLY ]

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 삼스

댓글을 달아 주세요

  1. 당신 매력있어, 자기가 얼마나 매력있는지 모르는게 당신매력이야

    2013.07.18 10:37 [ ADDR : EDIT/ DEL : REPLY ]