├── LICENSE ├── README.md ├── android-tools-4.2.2 ├── .applied_patches_list ├── .files-list.txt ├── .stamp_built ├── .stamp_configured ├── .stamp_downloaded ├── .stamp_extracted ├── .stamp_patched ├── .stamp_target_installed ├── core │ ├── adb │ │ ├── Makefile │ │ ├── abort_socket.o │ │ ├── adb │ │ ├── adb.c │ │ ├── adb.h │ │ ├── adb.o │ │ ├── adb_auth.h │ │ ├── adb_auth_client.c │ │ ├── adb_auth_host.c │ │ ├── adb_auth_host.o │ │ ├── adb_client.c │ │ ├── adb_client.h │ │ ├── adb_client.o │ │ ├── backup_service.c │ │ ├── centraldir.o │ │ ├── commandline.c │ │ ├── commandline.o │ │ ├── console.c │ │ ├── console.o │ │ ├── fdevent.c │ │ ├── fdevent.h │ │ ├── fdevent.o │ │ ├── file_sync_client.c │ │ ├── file_sync_client.o │ │ ├── file_sync_service.c │ │ ├── file_sync_service.h │ │ ├── framebuffer_service.c │ │ ├── get_my_path_darwin.c │ │ ├── get_my_path_freebsd.c │ │ ├── get_my_path_linux.c │ │ ├── get_my_path_linux.o │ │ ├── get_my_path_windows.c │ │ ├── jdwp_service.c │ │ ├── list.o │ │ ├── load_file.o │ │ ├── log_service.c │ │ ├── mutex_list.h │ │ ├── remount_service.c │ │ ├── services.c │ │ ├── services.o │ │ ├── socket_inaddr_any_server.o │ │ ├── socket_local_client.o │ │ ├── socket_local_server.o │ │ ├── socket_loopback_client.o │ │ ├── socket_loopback_server.o │ │ ├── socket_network_client.o │ │ ├── sockets.c │ │ ├── sockets.o │ │ ├── sysdeps.h │ │ ├── sysdeps_win32.c │ │ ├── test_track_devices.c │ │ ├── test_track_jdwp.c │ │ ├── transport.c │ │ ├── transport.h │ │ ├── transport.o │ │ ├── transport_local.c │ │ ├── transport_local.o │ │ ├── transport_usb.c │ │ ├── transport_usb.o │ │ ├── usb_libusb.c │ │ ├── usb_linux.c │ │ ├── usb_linux.o │ │ ├── usb_linux_client.c │ │ ├── usb_osx.c │ │ ├── usb_vendors.c │ │ ├── usb_vendors.h │ │ ├── usb_vendors.o │ │ ├── usb_windows.c │ │ ├── utils.c │ │ ├── utils.h │ │ ├── utils.o │ │ └── zipfile.o │ ├── adbd │ │ ├── Makefile │ │ ├── abort_socket.o │ │ ├── adb.c │ │ ├── adb.h │ │ ├── adb.o │ │ ├── adb_auth.h │ │ ├── adb_auth_client.c │ │ ├── adb_auth_client.o │ │ ├── adb_auth_host.c │ │ ├── adb_client.c │ │ ├── adb_client.h │ │ ├── adbd │ │ ├── android_filesystem_config.h │ │ ├── android_reboot.o │ │ ├── arpa_nameser.h │ │ ├── arpa_nameser_compat.h │ │ ├── backup_service.c │ │ ├── backup_service.o │ │ ├── base64.c │ │ ├── base64.o │ │ ├── centraldir.o │ │ ├── commandline.c │ │ ├── console.c │ │ ├── fdevent.c │ │ ├── fdevent.h │ │ ├── fdevent.o │ │ ├── file_sync_client.c │ │ ├── file_sync_service.c │ │ ├── file_sync_service.h │ │ ├── file_sync_service.o │ │ ├── framebuffer_service.c │ │ ├── framebuffer_service.o │ │ ├── functionfs.h │ │ ├── get_my_path_darwin.c │ │ ├── get_my_path_freebsd.c │ │ ├── get_my_path_linux.c │ │ ├── get_my_path_windows.c │ │ ├── jdwp_service.c │ │ ├── jdwp_service.o │ │ ├── list.o │ │ ├── load_file.o │ │ ├── log_service.c │ │ ├── log_service.o │ │ ├── mutex_list.h │ │ ├── qemu_pipe.h │ │ ├── remount_service.c │ │ ├── remount_service.o │ │ ├── services.c │ │ ├── services.o │ │ ├── socket_inaddr_any_server.o │ │ ├── socket_local_client.o │ │ ├── socket_local_server.o │ │ ├── socket_loopback_client.o │ │ ├── socket_loopback_server.o │ │ ├── socket_network_client.o │ │ ├── sockets.c │ │ ├── sockets.o │ │ ├── sysdeps.h │ │ ├── sysdeps_win32.c │ │ ├── test_track_devices.c │ │ ├── test_track_jdwp.c │ │ ├── transport.c │ │ ├── transport.h │ │ ├── transport.o │ │ ├── transport_local.c │ │ ├── transport_local.o │ │ ├── transport_usb.c │ │ ├── transport_usb.o │ │ ├── usb_libusb.c │ │ ├── usb_linux.c │ │ ├── usb_linux_client.c │ │ ├── usb_linux_client.o │ │ ├── usb_osx.c │ │ ├── usb_vendors.c │ │ ├── usb_vendors.h │ │ ├── usb_windows.c │ │ ├── utils.c │ │ ├── utils.h │ │ ├── utils.o │ │ └── zipfile.o │ ├── fastboot │ │ ├── bootimg.c │ │ ├── engine.c │ │ ├── fastboot.c │ │ ├── fastboot.h │ │ ├── protocol.c │ │ ├── usb.h │ │ ├── usb_linux.c │ │ ├── usb_osx.c │ │ ├── usb_windows.c │ │ ├── usbtest.c │ │ ├── util_linux.c │ │ ├── util_osx.c │ │ └── util_windows.c │ ├── include │ │ ├── cutils │ │ │ ├── abort_socket.h │ │ │ ├── android_reboot.h │ │ │ ├── array.h │ │ │ ├── ashmem.h │ │ │ ├── atomic-arm.h │ │ │ ├── atomic-inline.h │ │ │ ├── atomic-mips.h │ │ │ ├── atomic-x86.h │ │ │ ├── atomic.h │ │ │ ├── bitops.h │ │ │ ├── compiler.h │ │ │ ├── config_utils.h │ │ │ ├── cpu_info.h │ │ │ ├── debugger.h │ │ │ ├── dir_hash.h │ │ │ ├── event_tag_map.h │ │ │ ├── fs.h │ │ │ ├── hashmap.h │ │ │ ├── iosched_policy.h │ │ │ ├── jstring.h │ │ │ ├── klog.h │ │ │ ├── list.h │ │ │ ├── log.h │ │ │ ├── logd.h │ │ │ ├── logger.h │ │ │ ├── logprint.h │ │ │ ├── memory.h │ │ │ ├── misc.h │ │ │ ├── mq.h │ │ │ ├── multiuser.h │ │ │ ├── native_handle.h │ │ │ ├── open_memstream.h │ │ │ ├── partition_utils.h │ │ │ ├── process_name.h │ │ │ ├── properties.h │ │ │ ├── qsort_r_compat.h │ │ │ ├── qtaguid.h │ │ │ ├── record_stream.h │ │ │ ├── sched_policy.h │ │ │ ├── selector.h │ │ │ ├── sockets.h │ │ │ ├── str_parms.h │ │ │ ├── threads.h │ │ │ ├── tztime.h │ │ │ ├── uevent.h │ │ │ ├── uio.h │ │ │ └── zygote.h │ │ ├── mincrypt │ │ │ ├── rsa.h │ │ │ └── sha.h │ │ └── zipfile │ │ │ └── zipfile.h │ ├── libcutils │ │ ├── abort_socket.c │ │ ├── android_reboot.c │ │ ├── array.c │ │ ├── ashmem-dev.c │ │ ├── ashmem-host.c │ │ ├── atomic.c │ │ ├── buffer.c │ │ ├── buffer.h │ │ ├── config_utils.c │ │ ├── cpu_info.c │ │ ├── debugger.c │ │ ├── dir_hash.c │ │ ├── dlmalloc_stubs.c │ │ ├── fs.c │ │ ├── hashmap.c │ │ ├── iosched_policy.c │ │ ├── klog.c │ │ ├── list.c │ │ ├── load_file.c │ │ ├── loghack.h │ │ ├── memory.c │ │ ├── mq.c │ │ ├── multiuser.c │ │ ├── native_handle.c │ │ ├── open_memstream.c │ │ ├── partition_utils.c │ │ ├── process_name.c │ │ ├── properties.c │ │ ├── qsort_r_compat.c │ │ ├── qtaguid.c │ │ ├── record_stream.c │ │ ├── sched_policy.c │ │ ├── selector.c │ │ ├── socket_inaddr_any_server.c │ │ ├── socket_local.h │ │ ├── socket_local_client.c │ │ ├── socket_local_server.c │ │ ├── socket_loopback_client.c │ │ ├── socket_loopback_server.c │ │ ├── socket_network_client.c │ │ ├── sockets.c │ │ ├── str_parms.c │ │ ├── strdup16to8.c │ │ ├── strdup8to16.c │ │ ├── threads.c │ │ ├── uevent.c │ │ ├── uio.c │ │ └── zygote.c │ ├── libsparse │ │ ├── backed_block.c │ │ ├── backed_block.h │ │ ├── img2simg.c │ │ ├── include │ │ │ └── sparse │ │ │ │ └── sparse.h │ │ ├── output_file.c │ │ ├── output_file.h │ │ ├── simg2img.c │ │ ├── simg2simg.c │ │ ├── simg_dump.py │ │ ├── sparse.c │ │ ├── sparse_crc32.c │ │ ├── sparse_crc32.h │ │ ├── sparse_defs.h │ │ ├── sparse_err.c │ │ ├── sparse_file.h │ │ ├── sparse_format.h │ │ └── sparse_read.c │ ├── libzipfile │ │ ├── centraldir.c │ │ ├── private.h │ │ ├── test_zipfile.c │ │ └── zipfile.c │ └── mkbootimg │ │ ├── bootimg.h │ │ └── mkbootimg.c ├── debian │ ├── README.source │ ├── adb-completion │ ├── adb.1 │ ├── android-tools-adb.bash-completion │ ├── android-tools-adb.install │ ├── android-tools-adb.manpages │ ├── android-tools-adb.postinst │ ├── android-tools-adb.udev │ ├── android-tools-adbd.install │ ├── android-tools-adbd.udev │ ├── android-tools-adbd.upstart │ ├── android-tools-fastboot.bash-completion │ ├── android-tools-fastboot.install │ ├── android-tools-fastboot.udev │ ├── android-tools-fsutils.install │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── create-snapshot │ ├── fastboot-completion │ ├── makefiles │ │ ├── adb.mk │ │ ├── adbd.mk │ │ ├── ext4_utils.mk │ │ └── fastboot.mk │ ├── patches │ │ ├── add-bq-vendor-id.patch │ │ ├── add-meizu-vendor-id.patch │ │ ├── add_adbd.patch │ │ ├── enable-emulator.patch │ │ ├── ppc64el-ftbfs.patch │ │ ├── reboot-syscall.patch │ │ ├── remove-selinux-android.patch │ │ └── series │ ├── rules │ └── source │ │ └── format └── extras │ └── ext4_utils │ ├── allocate.c │ ├── allocate.h │ ├── contents.c │ ├── contents.h │ ├── crc16.c │ ├── ext2simg.c │ ├── ext4.h │ ├── ext4_extents.h │ ├── ext4_jbd2.h │ ├── ext4_utils.c │ ├── ext4_utils.h │ ├── ext4fixup.c │ ├── ext4fixup.h │ ├── ext4fixup_main.c │ ├── extent.c │ ├── extent.h │ ├── indirect.c │ ├── indirect.h │ ├── jbd2.h │ ├── make_ext4fs.c │ ├── make_ext4fs.h │ ├── make_ext4fs_main.c │ ├── mkuserimg.sh │ ├── setup_fs.c │ ├── sha1.c │ ├── sha1.h │ ├── test_ext4fixup │ ├── uuid.c │ ├── uuid.h │ ├── wipe.c │ ├── wipe.h │ └── xattr.h ├── openssl-1.0.0e.tar.gz └── zlib-1.2.11.tar.gz /README.md: -------------------------------------------------------------------------------- 1 | #### 介绍 2 | android-tools源码,方便不同平台移植。 3 | 4 | #### 使用说明 5 | 1.需要先安装zlib与openssl。详细安装流程查看 6 | 【ARM】简单移植adb与adbd过程记录 https://blog.csdn.net/chenwr2018/article/details/108118047 7 | 8 | 2.根据自己编译平台环境,自行修改对应目录下makefile中的编译器 9 | 10 | 3.以编译adb为例子,进入adb目录make即可在当前目录下生成adb二进制文件。 11 | 12 | -------------------------------------------------------------------------------- /android-tools-4.2.2/.applied_patches_list: -------------------------------------------------------------------------------- 1 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/remove-selinux-android.patch 2 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/add_adbd.patch 3 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/reboot-syscall.patch 4 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/enable-emulator.patch 5 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/ppc64el-ftbfs.patch 6 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/add-bq-vendor-id.patch 7 | /home/workspace/test/buildroot/buildroot-2020.02.3/output/build/android-tools-4.2.2+git20130218/debian/patches/add-meizu-vendor-id.patch 8 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0001-Fix-makefiles-for-out-of-tree-build.patch 9 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0002-Fix-adbd-for-non-Ubuntu-systems.patch 10 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0003-Fix-build-issue-with-uclibc.patch 11 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0004-Fix-build-issue-with-musl.patch 12 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0005-Use-pkgconf-to-get-libs-deps.patch 13 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0006-fix-big-endian-build.patch 14 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0007-include-cdefs-h-when-needed.patch 15 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0008-Include-sysmacros.h-to-compile-with-glibc-2.28.patch 16 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0009-Fix-makefiles-for-out-of-tree-ext4_utils-build.patch 17 | /home/workspace/test/buildroot/buildroot-2020.02.3/package/android-tools/0010-adb-added-patch-for-openssl-1.1.0-compatibility.patch 18 | -------------------------------------------------------------------------------- /android-tools-4.2.2/.files-list.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.files-list.txt -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_built: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_built -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_configured: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_configured -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_downloaded: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_downloaded -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_extracted: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_extracted -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_patched: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_patched -------------------------------------------------------------------------------- /android-tools-4.2.2/.stamp_target_installed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/.stamp_target_installed -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for adb; from https://heiher.info/2227.html 2 | # CC:=arm-oe-linux-gnueabi-gcc 3 | CC:=arm-hisiv100nptl-linux-gcc 4 | 5 | VPATH+= ./ 6 | SRCS+= adb.c 7 | SRCS+= adb_client.c 8 | SRCS+= adb_auth_host.c 9 | SRCS+= commandline.c 10 | SRCS+= console.c 11 | SRCS+= file_sync_client.c 12 | SRCS+= fdevent.c 13 | SRCS+= get_my_path_linux.c 14 | SRCS+= services.c 15 | SRCS+= sockets.c 16 | SRCS+= transport.c 17 | SRCS+= transport_local.c 18 | SRCS+= transport_usb.c 19 | SRCS+= usb_linux.c 20 | SRCS+= usb_vendors.c 21 | SRCS+= utils.c 22 | 23 | VPATH+= ../libcutils 24 | SRCS+= abort_socket.c 25 | SRCS+= socket_inaddr_any_server.c 26 | SRCS+= socket_local_client.c 27 | SRCS+= socket_local_server.c 28 | SRCS+= socket_loopback_client.c 29 | SRCS+= socket_loopback_server.c 30 | SRCS+= socket_network_client.c 31 | SRCS+= list.c 32 | SRCS+= load_file.c 33 | 34 | VPATH+= ../libzipfile 35 | SRCS+= centraldir.c 36 | SRCS+= zipfile.c 37 | 38 | 39 | CPPFLAGS+= -DADB_HOST=1 40 | CPPFLAGS+= -DHAVE_FORKEXEC=1 41 | CPPFLAGS+= -DHAVE_SYMLINKS 42 | CPPFLAGS+= -DHAVE_TERMIO_H 43 | CPPFLAGS+= -I./ 44 | CPPFLAGS+= -I../include 45 | # zlib openssl 头文件与库搜索路径 46 | CPPFLAGS+= -I/home/workspace/build/openssl/include 47 | CPPFLAGS+= -I/home/workspace/build/zlib/include 48 | 49 | LDFLAGS+= -L/home/workspace/build/zlib/lib 50 | LDFLAGS+= -L/home/workspace/build/openssl/lib 51 | LIBS+= -lc -lpthread -lz -lcrypto 52 | 53 | OBJS= $(SRCS:.c=.o) 54 | 55 | all: adb 56 | 57 | adb: $(OBJS) 58 | $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 59 | 60 | clean: 61 | rm -rf $(OBJS) adb 62 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/abort_socket.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/abort_socket.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/adb -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/adb.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __ADB_AUTH_H 18 | #define __ADB_AUTH_H 19 | 20 | void adb_auth_init(void); 21 | void adb_auth_verified(atransport *t); 22 | 23 | /* AUTH packets first argument */ 24 | /* Request */ 25 | #define ADB_AUTH_TOKEN 1 26 | /* Response */ 27 | #define ADB_AUTH_SIGNATURE 2 28 | #define ADB_AUTH_RSAPUBLICKEY 3 29 | 30 | #if ADB_HOST 31 | 32 | int adb_auth_sign(void *key, void *token, size_t token_size, void *sig); 33 | void *adb_auth_nextkey(void *current); 34 | int adb_auth_get_userkey(unsigned char *data, size_t len); 35 | 36 | static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; } 37 | static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; } 38 | static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { } 39 | static inline void adb_auth_reload_keys(void) { } 40 | 41 | #else // !ADB_HOST 42 | 43 | static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; } 44 | static inline void *adb_auth_nextkey(void *current) { return NULL; } 45 | static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; } 46 | 47 | int adb_auth_generate_token(void *token, size_t token_size); 48 | int adb_auth_verify(void *token, void *sig, int siglen); 49 | void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t); 50 | void adb_auth_reload_keys(void); 51 | 52 | #endif // ADB_HOST 53 | 54 | #endif // __ADB_AUTH_H 55 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb_auth_host.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/adb_auth_host.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb_client.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADB_CLIENT_H_ 2 | #define _ADB_CLIENT_H_ 3 | 4 | #include "adb.h" 5 | 6 | /* connect to adb, connect to the named service, and return 7 | ** a valid fd for interacting with that service upon success 8 | ** or a negative number on failure 9 | */ 10 | int adb_connect(const char *service); 11 | int _adb_connect(const char *service); 12 | 13 | /* connect to adb, connect to the named service, return 0 if 14 | ** the connection succeeded AND the service returned OKAY 15 | */ 16 | int adb_command(const char *service); 17 | 18 | /* connect to adb, connect to the named service, return 19 | ** a malloc'd string of its response upon success or NULL 20 | ** on failure. 21 | */ 22 | char *adb_query(const char *service); 23 | 24 | /* Set the preferred transport to connect to. 25 | */ 26 | void adb_set_transport(transport_type type, const char* serial); 27 | 28 | /* Set TCP specifics of the transport to use 29 | */ 30 | void adb_set_tcp_specifics(int server_port); 31 | 32 | /* Set TCP Hostname of the transport to use 33 | */ 34 | void adb_set_tcp_name(const char* hostname); 35 | 36 | /* Return the console port of the currently connected emulator (if any) 37 | * of -1 if there is no emulator, and -2 if there is more than one. 38 | * assumes adb_set_transport() was alled previously... 39 | */ 40 | int adb_get_emulator_console_port(void); 41 | 42 | /* send commands to the current emulator instance. will fail if there 43 | * is zero, or more than one emulator connected (or if you use -s 44 | * with a that does not designate an emulator) 45 | */ 46 | int adb_send_emulator_command(int argc, char** argv); 47 | 48 | /* return verbose error string from last operation */ 49 | const char *adb_error(void); 50 | 51 | /* read a standard adb status response (OKAY|FAIL) and 52 | ** return 0 in the event of OKAY, -1 in the event of FAIL 53 | ** or protocol error 54 | */ 55 | int adb_status(int fd); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/adb_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/adb_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/centraldir.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/centraldir.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/commandline.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/commandline.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/console.c: -------------------------------------------------------------------------------- 1 | #include "sysdeps.h" 2 | #include "adb.h" 3 | #include "adb_client.h" 4 | #include 5 | 6 | static int connect_to_console(void) 7 | { 8 | int fd, port; 9 | 10 | port = adb_get_emulator_console_port(); 11 | if (port < 0) { 12 | if (port == -2) 13 | fprintf(stderr, "error: more than one emulator detected. use -s option\n"); 14 | else 15 | fprintf(stderr, "error: no emulator detected\n"); 16 | return -1; 17 | } 18 | fd = socket_loopback_client( port, SOCK_STREAM ); 19 | if (fd < 0) { 20 | fprintf(stderr, "error: could not connect to TCP port %d\n", port); 21 | return -1; 22 | } 23 | return fd; 24 | } 25 | 26 | 27 | int adb_send_emulator_command(int argc, char** argv) 28 | { 29 | int fd, nn; 30 | 31 | fd = connect_to_console(); 32 | if (fd < 0) 33 | return 1; 34 | 35 | #define QUIT "quit\n" 36 | 37 | for (nn = 1; nn < argc; nn++) { 38 | adb_write( fd, argv[nn], strlen(argv[nn]) ); 39 | adb_write( fd, (nn == argc-1) ? "\n" : " ", 1 ); 40 | } 41 | adb_write( fd, QUIT, sizeof(QUIT)-1 ); 42 | adb_close(fd); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/console.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/console.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/fdevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __FDEVENT_H 18 | #define __FDEVENT_H 19 | 20 | #include /* for int64_t */ 21 | 22 | /* events that may be observed */ 23 | #define FDE_READ 0x0001 24 | #define FDE_WRITE 0x0002 25 | #define FDE_ERROR 0x0004 26 | #define FDE_TIMEOUT 0x0008 27 | 28 | /* features that may be set (via the events set/add/del interface) */ 29 | #define FDE_DONT_CLOSE 0x0080 30 | 31 | typedef struct fdevent fdevent; 32 | 33 | typedef void (*fd_func)(int fd, unsigned events, void *userdata); 34 | 35 | /* Allocate and initialize a new fdevent object 36 | * Note: use FD_TIMER as 'fd' to create a fd-less object 37 | * (used to implement timers). 38 | */ 39 | fdevent *fdevent_create(int fd, fd_func func, void *arg); 40 | 41 | /* Uninitialize and deallocate an fdevent object that was 42 | ** created by fdevent_create() 43 | */ 44 | void fdevent_destroy(fdevent *fde); 45 | 46 | /* Initialize an fdevent object that was externally allocated 47 | */ 48 | void fdevent_install(fdevent *fde, int fd, fd_func func, void *arg); 49 | 50 | /* Uninitialize an fdevent object that was initialized by 51 | ** fdevent_install() 52 | */ 53 | void fdevent_remove(fdevent *item); 54 | 55 | /* Change which events should cause notifications 56 | */ 57 | void fdevent_set(fdevent *fde, unsigned events); 58 | void fdevent_add(fdevent *fde, unsigned events); 59 | void fdevent_del(fdevent *fde, unsigned events); 60 | 61 | void fdevent_set_timeout(fdevent *fde, int64_t timeout_ms); 62 | 63 | /* loop forever, handling events. 64 | */ 65 | void fdevent_loop(); 66 | 67 | struct fdevent 68 | { 69 | fdevent *next; 70 | fdevent *prev; 71 | 72 | int fd; 73 | int force_eof; 74 | 75 | unsigned short state; 76 | unsigned short events; 77 | 78 | fd_func func; 79 | void *arg; 80 | }; 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/fdevent.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/fdevent.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/file_sync_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/file_sync_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/get_my_path_darwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #include 19 | 20 | void get_my_path(char *s, size_t maxLen) 21 | { 22 | ProcessSerialNumber psn; 23 | GetCurrentProcess(&psn); 24 | CFDictionaryRef dict; 25 | dict = ProcessInformationCopyDictionary(&psn, 0xffffffff); 26 | CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict, 27 | CFSTR("CFBundleExecutable")); 28 | CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/get_my_path_freebsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 bsdroid project 3 | * Alexey Tarasov 4 | * 5 | * Copyright (C) 2007 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void 26 | get_my_path(char *exe, size_t maxLen) 27 | { 28 | char proc[64]; 29 | 30 | snprintf(proc, sizeof(proc), "/proc/%d/file", getpid()); 31 | 32 | int err = readlink(proc, exe, maxLen - 1); 33 | 34 | exe[err > 0 ? err : 0] = '\0'; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/get_my_path_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void get_my_path(char *exe, size_t maxLen) 23 | { 24 | char proc[64]; 25 | snprintf(proc, sizeof proc, "/proc/%d/exe", getpid()); 26 | int err = readlink(proc, exe, maxLen - 1); 27 | if(err > 0) { 28 | exe[err] = '\0'; 29 | } else { 30 | exe[0] = '\0'; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/get_my_path_linux.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/get_my_path_linux.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/get_my_path_windows.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | void get_my_path(char *exe, size_t maxLen) 22 | { 23 | char *r; 24 | 25 | /* XXX: should be GetModuleFileNameA */ 26 | if (GetModuleFileName(NULL, exe, maxLen) > 0) { 27 | r = strrchr(exe, '\\'); 28 | if (r != NULL) 29 | *r = '\0'; 30 | } else { 31 | exe[0] = '\0'; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/list.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/list.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/load_file.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/load_file.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/mutex_list.h: -------------------------------------------------------------------------------- 1 | /* the list of mutexes used by adb */ 2 | /* #ifndef __MUTEX_LIST_H 3 | * Do not use an include-guard. This file is included once to declare the locks 4 | * and once in win32 to actually do the runtime initialization. 5 | */ 6 | #ifndef ADB_MUTEX 7 | #error ADB_MUTEX not defined when including this file 8 | #endif 9 | ADB_MUTEX(dns_lock) 10 | ADB_MUTEX(socket_list_lock) 11 | ADB_MUTEX(transport_lock) 12 | #if ADB_HOST 13 | ADB_MUTEX(local_transports_lock) 14 | #endif 15 | ADB_MUTEX(usb_lock) 16 | 17 | // Sadly logging to /data/adb/adb-... is not thread safe. 18 | // After modifying adb.h::D() to count invocations: 19 | // DEBUG(jpa):0:Handling main() 20 | // DEBUG(jpa):1:[ usb_init - starting thread ] 21 | // (Oopsies, no :2:, and matching message is also gone.) 22 | // DEBUG(jpa):3:[ usb_thread - opening device ] 23 | // DEBUG(jpa):4:jdwp control socket started (10) 24 | ADB_MUTEX(D_lock) 25 | 26 | #undef ADB_MUTEX 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/services.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/services.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_inaddr_any_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_inaddr_any_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_local_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_local_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_local_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_local_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_loopback_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_loopback_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_loopback_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_loopback_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/socket_network_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/socket_network_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/sockets.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/sockets.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __TRANSPORT_H 18 | #define __TRANSPORT_H 19 | 20 | /* convenience wrappers around read/write that will retry on 21 | ** EINTR and/or short read/write. Returns 0 on success, -1 22 | ** on error or EOF. 23 | */ 24 | int readx(int fd, void *ptr, size_t len); 25 | int writex(int fd, const void *ptr, size_t len); 26 | #endif /* __TRANSPORT_H */ 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/transport.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/transport.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/transport_local.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/transport_local.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/transport_usb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/transport_usb.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/usb_linux.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/usb_linux.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/usb_vendors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __USB_VENDORS_H 18 | #define __USB_VENDORS_H 19 | 20 | extern int vendorIds[]; 21 | extern unsigned vendorIdCount; 22 | 23 | void usb_vendors_init(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/usb_vendors.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/usb_vendors.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/utils.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/utils.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adb/zipfile.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adb/zipfile.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for adbd 2 | #CC:=arm-oe-linux-gnueabi-gcc 3 | CC:=arm-hisiv100nptl-linux-gcc 4 | 5 | VPATH+= ./ 6 | SRCS+= adb.c 7 | SRCS+= backup_service.c 8 | SRCS+= fdevent.c 9 | SRCS+= transport.c 10 | SRCS+= transport_local.c 11 | SRCS+= transport_usb.c 12 | SRCS+= adb_auth_client.c 13 | SRCS+= sockets.c 14 | SRCS+= services.c 15 | SRCS+= file_sync_service.c 16 | SRCS+= jdwp_service.c 17 | SRCS+= framebuffer_service.c 18 | SRCS+= remount_service.c 19 | SRCS+= usb_linux_client.c 20 | SRCS+= log_service.c 21 | SRCS+= utils.c 22 | SRCS+= base64.c 23 | 24 | VPATH+= ../libcutils 25 | SRCS+= abort_socket.c 26 | SRCS+= socket_inaddr_any_server.c 27 | SRCS+= socket_local_client.c 28 | SRCS+= socket_local_server.c 29 | SRCS+= socket_loopback_client.c 30 | SRCS+= socket_loopback_server.c 31 | SRCS+= socket_network_client.c 32 | SRCS+= list.c 33 | SRCS+= load_file.c 34 | SRCS+= android_reboot.c 35 | 36 | VPATH+= ../libzipfile 37 | SRCS+= centraldir.c 38 | SRCS+= zipfile.c 39 | 40 | 41 | CPPFLAGS+= -O2 -g -Wall -Wno-unused-parameter 42 | CPPFLAGS+= -DADB_HOST=0 -DHAVE_FORKEXEC=1 -D_XOPEN_SOURCE -D_GNU_SOURCE -DALLOW_ADBD_ROOT=1 43 | CPPFLAGS+= -DHAVE_SYMLINKS -DBOARD_ALWAYS_INSECURE 44 | CPPFLAGS+= -DHAVE_TERMIO_H 45 | CPPFLAGS+= -DADBD_NON_ANDROID 46 | CPPFLAGS+= -I./ 47 | CPPFLAGS+= -I../include 48 | 49 | # 设置zlib openssl 头文件与库搜索路径 50 | CPPFLAGS+= -I/home/workspace/build/openssl/include 51 | CPPFLAGS+= -I/home/workspace/build/zlib/include 52 | 53 | LDFLAGS+= -L/home/workspace/build/zlib/lib 54 | LDFLAGS+= -L/home/workspace/build/openssl/lib 55 | 56 | LIBS+= -lc -lpthread -lz -lcrypto -lcrypt 57 | 58 | OBJS= $(patsubst %, %.o, $(basename $(SRCS))) 59 | 60 | all: adbd 61 | 62 | adbd: $(OBJS) 63 | $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 64 | 65 | #%.o: 66 | # echo $(OBJS) 67 | # $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) -c $(wildcard $(addprefix $(CURDIR)/../*/,$(patsubst %.o, %.c, $@))) 68 | clean: 69 | rm -rf $(OBJS) adbd 70 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/abort_socket.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/abort_socket.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/adb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/adb.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/adb_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __ADB_AUTH_H 18 | #define __ADB_AUTH_H 19 | 20 | void adb_auth_init(void); 21 | void adb_auth_verified(atransport *t); 22 | 23 | /* AUTH packets first argument */ 24 | /* Request */ 25 | #define ADB_AUTH_TOKEN 1 26 | /* Response */ 27 | #define ADB_AUTH_SIGNATURE 2 28 | #define ADB_AUTH_RSAPUBLICKEY 3 29 | 30 | #if ADB_HOST 31 | 32 | int adb_auth_sign(void *key, void *token, size_t token_size, void *sig); 33 | void *adb_auth_nextkey(void *current); 34 | int adb_auth_get_userkey(unsigned char *data, size_t len); 35 | 36 | static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; } 37 | static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; } 38 | static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { } 39 | static inline void adb_auth_reload_keys(void) { } 40 | 41 | #else // !ADB_HOST 42 | 43 | static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; } 44 | static inline void *adb_auth_nextkey(void *current) { return NULL; } 45 | static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; } 46 | 47 | int adb_auth_generate_token(void *token, size_t token_size); 48 | int adb_auth_verify(void *token, void *sig, int siglen); 49 | void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t); 50 | void adb_auth_reload_keys(void); 51 | 52 | #endif // ADB_HOST 53 | 54 | #endif // __ADB_AUTH_H 55 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/adb_auth_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/adb_auth_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/adb_client.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADB_CLIENT_H_ 2 | #define _ADB_CLIENT_H_ 3 | 4 | #include "adb.h" 5 | 6 | /* connect to adb, connect to the named service, and return 7 | ** a valid fd for interacting with that service upon success 8 | ** or a negative number on failure 9 | */ 10 | int adb_connect(const char *service); 11 | int _adb_connect(const char *service); 12 | 13 | /* connect to adb, connect to the named service, return 0 if 14 | ** the connection succeeded AND the service returned OKAY 15 | */ 16 | int adb_command(const char *service); 17 | 18 | /* connect to adb, connect to the named service, return 19 | ** a malloc'd string of its response upon success or NULL 20 | ** on failure. 21 | */ 22 | char *adb_query(const char *service); 23 | 24 | /* Set the preferred transport to connect to. 25 | */ 26 | void adb_set_transport(transport_type type, const char* serial); 27 | 28 | /* Set TCP specifics of the transport to use 29 | */ 30 | void adb_set_tcp_specifics(int server_port); 31 | 32 | /* Set TCP Hostname of the transport to use 33 | */ 34 | void adb_set_tcp_name(const char* hostname); 35 | 36 | /* Return the console port of the currently connected emulator (if any) 37 | * of -1 if there is no emulator, and -2 if there is more than one. 38 | * assumes adb_set_transport() was alled previously... 39 | */ 40 | int adb_get_emulator_console_port(void); 41 | 42 | /* send commands to the current emulator instance. will fail if there 43 | * is zero, or more than one emulator connected (or if you use -s 44 | * with a that does not designate an emulator) 45 | */ 46 | int adb_send_emulator_command(int argc, char** argv); 47 | 48 | /* return verbose error string from last operation */ 49 | const char *adb_error(void); 50 | 51 | /* read a standard adb status response (OKAY|FAIL) and 52 | ** return 0 in the event of OKAY, -1 in the event of FAIL 53 | ** or protocol error 54 | */ 55 | int adb_status(int fd); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/adbd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/adbd -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/android_reboot.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/android_reboot.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/backup_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/backup_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/base64.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/base64.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/centraldir.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/centraldir.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/console.c: -------------------------------------------------------------------------------- 1 | #include "sysdeps.h" 2 | #include "adb.h" 3 | #include "adb_client.h" 4 | #include 5 | 6 | static int connect_to_console(void) 7 | { 8 | int fd, port; 9 | 10 | port = adb_get_emulator_console_port(); 11 | if (port < 0) { 12 | if (port == -2) 13 | fprintf(stderr, "error: more than one emulator detected. use -s option\n"); 14 | else 15 | fprintf(stderr, "error: no emulator detected\n"); 16 | return -1; 17 | } 18 | fd = socket_loopback_client( port, SOCK_STREAM ); 19 | if (fd < 0) { 20 | fprintf(stderr, "error: could not connect to TCP port %d\n", port); 21 | return -1; 22 | } 23 | return fd; 24 | } 25 | 26 | 27 | int adb_send_emulator_command(int argc, char** argv) 28 | { 29 | int fd, nn; 30 | 31 | fd = connect_to_console(); 32 | if (fd < 0) 33 | return 1; 34 | 35 | #define QUIT "quit\n" 36 | 37 | for (nn = 1; nn < argc; nn++) { 38 | adb_write( fd, argv[nn], strlen(argv[nn]) ); 39 | adb_write( fd, (nn == argc-1) ? "\n" : " ", 1 ); 40 | } 41 | adb_write( fd, QUIT, sizeof(QUIT)-1 ); 42 | adb_close(fd); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/fdevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __FDEVENT_H 18 | #define __FDEVENT_H 19 | 20 | #include /* for int64_t */ 21 | 22 | /* events that may be observed */ 23 | #define FDE_READ 0x0001 24 | #define FDE_WRITE 0x0002 25 | #define FDE_ERROR 0x0004 26 | #define FDE_TIMEOUT 0x0008 27 | 28 | /* features that may be set (via the events set/add/del interface) */ 29 | #define FDE_DONT_CLOSE 0x0080 30 | 31 | typedef struct fdevent fdevent; 32 | 33 | typedef void (*fd_func)(int fd, unsigned events, void *userdata); 34 | 35 | /* Allocate and initialize a new fdevent object 36 | * Note: use FD_TIMER as 'fd' to create a fd-less object 37 | * (used to implement timers). 38 | */ 39 | fdevent *fdevent_create(int fd, fd_func func, void *arg); 40 | 41 | /* Uninitialize and deallocate an fdevent object that was 42 | ** created by fdevent_create() 43 | */ 44 | void fdevent_destroy(fdevent *fde); 45 | 46 | /* Initialize an fdevent object that was externally allocated 47 | */ 48 | void fdevent_install(fdevent *fde, int fd, fd_func func, void *arg); 49 | 50 | /* Uninitialize an fdevent object that was initialized by 51 | ** fdevent_install() 52 | */ 53 | void fdevent_remove(fdevent *item); 54 | 55 | /* Change which events should cause notifications 56 | */ 57 | void fdevent_set(fdevent *fde, unsigned events); 58 | void fdevent_add(fdevent *fde, unsigned events); 59 | void fdevent_del(fdevent *fde, unsigned events); 60 | 61 | void fdevent_set_timeout(fdevent *fde, int64_t timeout_ms); 62 | 63 | /* loop forever, handling events. 64 | */ 65 | void fdevent_loop(); 66 | 67 | struct fdevent 68 | { 69 | fdevent *next; 70 | fdevent *prev; 71 | 72 | int fd; 73 | int force_eof; 74 | 75 | unsigned short state; 76 | unsigned short events; 77 | 78 | fd_func func; 79 | void *arg; 80 | }; 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/fdevent.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/fdevent.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/file_sync_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/file_sync_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/framebuffer_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/framebuffer_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/get_my_path_darwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #include 19 | 20 | void get_my_path(char *s, size_t maxLen) 21 | { 22 | ProcessSerialNumber psn; 23 | GetCurrentProcess(&psn); 24 | CFDictionaryRef dict; 25 | dict = ProcessInformationCopyDictionary(&psn, 0xffffffff); 26 | CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict, 27 | CFSTR("CFBundleExecutable")); 28 | CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/get_my_path_freebsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 bsdroid project 3 | * Alexey Tarasov 4 | * 5 | * Copyright (C) 2007 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void 26 | get_my_path(char *exe, size_t maxLen) 27 | { 28 | char proc[64]; 29 | 30 | snprintf(proc, sizeof(proc), "/proc/%d/file", getpid()); 31 | 32 | int err = readlink(proc, exe, maxLen - 1); 33 | 34 | exe[err > 0 ? err : 0] = '\0'; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/get_my_path_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void get_my_path(char *exe, size_t maxLen) 23 | { 24 | char proc[64]; 25 | snprintf(proc, sizeof proc, "/proc/%d/exe", getpid()); 26 | int err = readlink(proc, exe, maxLen - 1); 27 | if(err > 0) { 28 | exe[err] = '\0'; 29 | } else { 30 | exe[0] = '\0'; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/get_my_path_windows.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | void get_my_path(char *exe, size_t maxLen) 22 | { 23 | char *r; 24 | 25 | /* XXX: should be GetModuleFileNameA */ 26 | if (GetModuleFileName(NULL, exe, maxLen) > 0) { 27 | r = strrchr(exe, '\\'); 28 | if (r != NULL) 29 | *r = '\0'; 30 | } else { 31 | exe[0] = '\0'; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/jdwp_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/jdwp_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/list.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/list.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/load_file.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/load_file.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/log_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/log_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/mutex_list.h: -------------------------------------------------------------------------------- 1 | /* the list of mutexes used by adb */ 2 | /* #ifndef __MUTEX_LIST_H 3 | * Do not use an include-guard. This file is included once to declare the locks 4 | * and once in win32 to actually do the runtime initialization. 5 | */ 6 | #ifndef ADB_MUTEX 7 | #error ADB_MUTEX not defined when including this file 8 | #endif 9 | ADB_MUTEX(dns_lock) 10 | ADB_MUTEX(socket_list_lock) 11 | ADB_MUTEX(transport_lock) 12 | #if ADB_HOST 13 | ADB_MUTEX(local_transports_lock) 14 | #endif 15 | ADB_MUTEX(usb_lock) 16 | 17 | // Sadly logging to /data/adb/adb-... is not thread safe. 18 | // After modifying adb.h::D() to count invocations: 19 | // DEBUG(jpa):0:Handling main() 20 | // DEBUG(jpa):1:[ usb_init - starting thread ] 21 | // (Oopsies, no :2:, and matching message is also gone.) 22 | // DEBUG(jpa):3:[ usb_thread - opening device ] 23 | // DEBUG(jpa):4:jdwp control socket started (10) 24 | ADB_MUTEX(D_lock) 25 | 26 | #undef ADB_MUTEX 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/remount_service.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/remount_service.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/services.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/services.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_inaddr_any_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_inaddr_any_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_local_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_local_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_local_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_local_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_loopback_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_loopback_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_loopback_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_loopback_server.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/socket_network_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/socket_network_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/sockets.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/sockets.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __TRANSPORT_H 18 | #define __TRANSPORT_H 19 | 20 | /* convenience wrappers around read/write that will retry on 21 | ** EINTR and/or short read/write. Returns 0 on success, -1 22 | ** on error or EOF. 23 | */ 24 | int readx(int fd, void *ptr, size_t len); 25 | int writex(int fd, const void *ptr, size_t len); 26 | #endif /* __TRANSPORT_H */ 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/transport.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/transport.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/transport_local.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/transport_local.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/transport_usb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/transport_usb.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/usb_linux_client.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/usb_linux_client.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/usb_vendors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __USB_VENDORS_H 18 | #define __USB_VENDORS_H 19 | 20 | extern int vendorIds[]; 21 | extern unsigned vendorIdCount; 22 | 23 | void usb_vendors_init(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/utils.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/utils.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/adbd/zipfile.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenwr2018/study_record/1aeedaf03376a17c66516ddaa71b33059eaeb9db/android-tools-4.2.2/core/adbd/zipfile.o -------------------------------------------------------------------------------- /android-tools-4.2.2/core/fastboot/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _USB_H_ 30 | #define _USB_H_ 31 | 32 | typedef struct usb_handle usb_handle; 33 | 34 | typedef struct usb_ifc_info usb_ifc_info; 35 | 36 | struct usb_ifc_info 37 | { 38 | /* from device descriptor */ 39 | unsigned short dev_vendor; 40 | unsigned short dev_product; 41 | 42 | unsigned char dev_class; 43 | unsigned char dev_subclass; 44 | unsigned char dev_protocol; 45 | 46 | unsigned char ifc_class; 47 | unsigned char ifc_subclass; 48 | unsigned char ifc_protocol; 49 | 50 | unsigned char has_bulk_in; 51 | unsigned char has_bulk_out; 52 | 53 | unsigned char writable; 54 | 55 | char serial_number[256]; 56 | char device_path[256]; 57 | }; 58 | 59 | typedef int (*ifc_match_func)(usb_ifc_info *ifc); 60 | 61 | usb_handle *usb_open(ifc_match_func callback); 62 | int usb_close(usb_handle *h); 63 | int usb_read(usb_handle *h, void *_data, int len); 64 | int usb_write(usb_handle *h, const void *_data, int len); 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/fastboot/util_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | void get_my_path(char *path) 38 | { 39 | char proc[64]; 40 | char *x; 41 | 42 | sprintf(proc, "/proc/%d/exe", getpid()); 43 | int err = readlink(proc, path, PATH_MAX - 1); 44 | 45 | if(err <= 0) { 46 | path[0] = 0; 47 | } else { 48 | path[err] = 0; 49 | x = strrchr(path,'/'); 50 | if(x) x[1] = 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/fastboot/util_osx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | #include 31 | 32 | void get_my_path(char s[PATH_MAX]) 33 | { 34 | char *x; 35 | ProcessSerialNumber psn; 36 | GetCurrentProcess(&psn); 37 | CFDictionaryRef dict; 38 | dict = ProcessInformationCopyDictionary(&psn, 0xffffffff); 39 | CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict, 40 | CFSTR("CFBundleExecutable")); 41 | CFStringGetCString(value, s, PATH_MAX - 1, kCFStringEncodingUTF8); 42 | x = strrchr(s, '/'); 43 | if(x) x[1] = 0; 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/android_reboot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_ANDROID_REBOOT_H__ 18 | #define __CUTILS_ANDROID_REBOOT_H__ 19 | 20 | __BEGIN_DECLS 21 | 22 | /* Commands */ 23 | #define ANDROID_RB_RESTART 0xDEAD0001 24 | #define ANDROID_RB_POWEROFF 0xDEAD0002 25 | #define ANDROID_RB_RESTART2 0xDEAD0003 26 | 27 | /* Flags */ 28 | #define ANDROID_RB_FLAG_NO_SYNC 0x1 29 | #define ANDROID_RB_FLAG_NO_REMOUNT_RO 0x2 30 | 31 | int android_reboot(int cmd, int flags, char *arg); 32 | 33 | __END_DECLS 34 | 35 | #endif /* __CUTILS_ANDROID_REBOOT_H__ */ 36 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/array.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * A pointer array which intelligently expands its capacity ad needed. 19 | */ 20 | 21 | #ifndef __ARRAY_H 22 | #define __ARRAY_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | /** An array. */ 31 | typedef struct Array Array; 32 | 33 | /** Constructs a new array. Returns NULL if we ran out of memory. */ 34 | Array* arrayCreate(); 35 | 36 | /** Frees an array. Does not free elements themselves. */ 37 | void arrayFree(Array* array); 38 | 39 | /** Adds a pointer. Returns 0 is successful, < 0 otherwise. */ 40 | int arrayAdd(Array* array, void* pointer); 41 | 42 | /** Gets the pointer at the specified index. */ 43 | void* arrayGet(Array* array, int index); 44 | 45 | /** Removes the pointer at the given index and returns it. */ 46 | void* arrayRemove(Array* array, int index); 47 | 48 | /** Sets pointer at the given index. Returns old pointer. */ 49 | void* arraySet(Array* array, int index, void* pointer); 50 | 51 | /** Sets the array size. Sets new pointers to NULL. Returns 0 if successful, < 0 otherwise . */ 52 | int arraySetSize(Array* array, int size); 53 | 54 | /** Returns the size of the given array. */ 55 | int arraySize(Array* array); 56 | 57 | /** 58 | * Returns a pointer to a C-style array which will be valid until this array 59 | * changes. 60 | */ 61 | const void** arrayUnwrap(Array* array); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __ARRAY_H */ 68 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/ashmem.h: -------------------------------------------------------------------------------- 1 | /* cutils/ashmem.h 2 | ** 3 | ** Copyright 2008 The Android Open Source Project 4 | ** 5 | ** This file is dual licensed. It may be redistributed and/or modified 6 | ** under the terms of the Apache 2.0 License OR version 2 of the GNU 7 | ** General Public License. 8 | */ 9 | 10 | #ifndef _CUTILS_ASHMEM_H 11 | #define _CUTILS_ASHMEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | int ashmem_create_region(const char *name, size_t size); 20 | int ashmem_set_prot_region(int fd, int prot); 21 | int ashmem_pin_region(int fd, size_t offset, size_t len); 22 | int ashmem_unpin_region(int fd, size_t offset, size_t len); 23 | int ashmem_get_size_region(int fd); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #ifndef __ASHMEMIOC /* in case someone included too */ 30 | 31 | #define ASHMEM_NAME_LEN 256 32 | 33 | #define ASHMEM_NAME_DEF "dev/ashmem" 34 | 35 | /* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ 36 | #define ASHMEM_NOT_PURGED 0 37 | #define ASHMEM_WAS_PURGED 1 38 | 39 | /* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ 40 | #define ASHMEM_IS_UNPINNED 0 41 | #define ASHMEM_IS_PINNED 1 42 | 43 | #endif /* ! __ASHMEMIOC */ 44 | 45 | #endif /* _CUTILS_ASHMEM_H */ 46 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/atomic-inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_CUTILS_ATOMIC_INLINE_H 18 | #define ANDROID_CUTILS_ATOMIC_INLINE_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* 25 | * Inline declarations and macros for some special-purpose atomic 26 | * operations. These are intended for rare circumstances where a 27 | * memory barrier needs to be issued inline rather than as a function 28 | * call. 29 | * 30 | * Most code should not use these. 31 | * 32 | * Anything that does include this file must set ANDROID_SMP to either 33 | * 0 or 1, indicating compilation for UP or SMP, respectively. 34 | * 35 | * Macros defined in this header: 36 | * 37 | * void ANDROID_MEMBAR_FULL(void) 38 | * Full memory barrier. Provides a compiler reordering barrier, and 39 | * on SMP systems emits an appropriate instruction. 40 | */ 41 | 42 | #if !defined(ANDROID_SMP) 43 | # error "Must define ANDROID_SMP before including atomic-inline.h" 44 | #endif 45 | 46 | #if defined(__arm__) 47 | #include 48 | #elif defined(__i386__) || defined(__x86_64__) 49 | #include 50 | #elif defined(__mips__) 51 | #include 52 | #else 53 | #error atomic operations are unsupported 54 | #endif 55 | 56 | #if ANDROID_SMP == 0 57 | #define ANDROID_MEMBAR_FULL android_compiler_barrier 58 | #else 59 | #define ANDROID_MEMBAR_FULL android_memory_barrier 60 | #endif 61 | 62 | #if ANDROID_SMP == 0 63 | #define ANDROID_MEMBAR_STORE android_compiler_barrier 64 | #else 65 | #define ANDROID_MEMBAR_STORE android_memory_store_barrier 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ 73 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/bitops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_BITOPS_H 18 | #define __CUTILS_BITOPS_H 19 | 20 | #include 21 | 22 | __BEGIN_DECLS 23 | 24 | static inline int popcount(unsigned int x) 25 | { 26 | return __builtin_popcount(x); 27 | } 28 | 29 | static inline int popcountl(unsigned long x) 30 | { 31 | return __builtin_popcountl(x); 32 | } 33 | 34 | static inline int popcountll(unsigned long long x) 35 | { 36 | return __builtin_popcountll(x); 37 | } 38 | 39 | __END_DECLS 40 | 41 | #endif /* __CUTILS_BITOPS_H */ 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_CUTILS_COMPILER_H 18 | #define ANDROID_CUTILS_COMPILER_H 19 | 20 | /* 21 | * helps the compiler's optimizer predicting branches 22 | */ 23 | 24 | #ifdef __cplusplus 25 | # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) 26 | # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) 27 | #else 28 | # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) 29 | # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) 30 | #endif 31 | 32 | /** 33 | * exports marked symbols 34 | * 35 | * if used on a C++ class declaration, this macro must be inserted 36 | * after the "class" keyword. For instance: 37 | * 38 | * template 39 | * class ANDROID_API Singleton { } 40 | */ 41 | 42 | #define ANDROID_API __attribute__((visibility("default"))) 43 | 44 | #endif // ANDROID_CUTILS_COMPILER_H 45 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/config_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_CONFIG_UTILS_H 18 | #define __CUTILS_CONFIG_UTILS_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct cnode cnode; 25 | 26 | 27 | struct cnode 28 | { 29 | cnode *next; 30 | cnode *first_child; 31 | cnode *last_child; 32 | const char *name; 33 | const char *value; 34 | }; 35 | 36 | /* parse a text string into a config node tree */ 37 | void config_load(cnode *root, char *data); 38 | 39 | /* parse a file into a config node tree */ 40 | void config_load_file(cnode *root, const char *fn); 41 | 42 | /* create a single config node */ 43 | cnode* config_node(const char *name, const char *value); 44 | 45 | /* locate a named child of a config node */ 46 | cnode* config_find(cnode *root, const char *name); 47 | 48 | /* look up a child by name and return the boolean value */ 49 | int config_bool(cnode *root, const char *name, int _default); 50 | 51 | /* look up a child by name and return the string value */ 52 | const char* config_str(cnode *root, const char *name, const char *_default); 53 | 54 | /* add a named child to a config node (or modify it if it already exists) */ 55 | void config_set(cnode *root, const char *name, const char *value); 56 | 57 | /* free a config node tree */ 58 | void config_free(cnode *root); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/cpu_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_CPU_INFO_H 18 | #define __CUTILS_CPU_INFO_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* returns a string contiaining an ASCII representation of the CPU serial number, 25 | ** or NULL if cpu info not available. 26 | ** The string is a static variable, so don't call free() on it. 27 | */ 28 | extern const char* get_cpu_serial_number(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* __CUTILS_CPU_INFO_H */ 35 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/debugger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_DEBUGGER_H 18 | #define __CUTILS_DEBUGGER_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #define DEBUGGER_SOCKET_NAME "android:debuggerd" 27 | 28 | typedef enum { 29 | // dump a crash 30 | DEBUGGER_ACTION_CRASH, 31 | // dump a tombstone file 32 | DEBUGGER_ACTION_DUMP_TOMBSTONE, 33 | // dump a backtrace only back to the socket 34 | DEBUGGER_ACTION_DUMP_BACKTRACE, 35 | } debugger_action_t; 36 | 37 | /* message sent over the socket */ 38 | typedef struct { 39 | debugger_action_t action; 40 | pid_t tid; 41 | } debugger_msg_t; 42 | 43 | /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). 44 | * Stores the tombstone path in the provided buffer. 45 | * Returns 0 on success, -1 on error. 46 | */ 47 | int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); 48 | 49 | /* Dumps a process backtrace only to the specified file (requires root). 50 | * Returns 0 on success, -1 on error. 51 | */ 52 | int dump_backtrace_to_file(pid_t tid, int fd); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif /* __CUTILS_DEBUGGER_H */ 59 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/dir_hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | typedef enum { 18 | SHA_1, 19 | } HashAlgorithm; 20 | 21 | int get_file_hash(HashAlgorithm algorithm, const char *path, 22 | char *output_string, size_t max_output_string); 23 | 24 | int get_recursive_hash_manifest(HashAlgorithm algorithm, 25 | const char *directory_path, 26 | char **output_string); 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/event_tag_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBS_CUTILS_EVENTTAGMAP_H 18 | #define _LIBS_CUTILS_EVENTTAGMAP_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" 25 | 26 | struct EventTagMap; 27 | typedef struct EventTagMap EventTagMap; 28 | 29 | /* 30 | * Open the specified file as an event log tag map. 31 | * 32 | * Returns NULL on failure. 33 | */ 34 | EventTagMap* android_openEventTagMap(const char* fileName); 35 | 36 | /* 37 | * Close the map. 38 | */ 39 | void android_closeEventTagMap(EventTagMap* map); 40 | 41 | /* 42 | * Look up a tag by index. Returns the tag string, or NULL if not found. 43 | */ 44 | const char* android_lookupEventTag(const EventTagMap* map, int tag); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ 51 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_FS_H 18 | #define __CUTILS_FS_H 19 | 20 | #include 21 | 22 | /* 23 | * TEMP_FAILURE_RETRY is defined by some, but not all, versions of 24 | * . (Alas, it is not as standard as we'd hoped!) So, if it's 25 | * not already defined, then define it here. 26 | */ 27 | #ifndef TEMP_FAILURE_RETRY 28 | /* Used to retry syscalls that can return EINTR. */ 29 | #define TEMP_FAILURE_RETRY(exp) ({ \ 30 | typeof (exp) _rc; \ 31 | do { \ 32 | _rc = (exp); \ 33 | } while (_rc == -1 && errno == EINTR); \ 34 | _rc; }) 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* 42 | * Ensure that directory exists with given mode and owners. 43 | */ 44 | extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); 45 | 46 | /* 47 | * Read single plaintext integer from given file, correctly handling files 48 | * partially written with fs_write_atomic_int(). 49 | */ 50 | extern int fs_read_atomic_int(const char* path, int* value); 51 | 52 | /* 53 | * Write single plaintext integer to given file, creating backup while 54 | * in progress. 55 | */ 56 | extern int fs_write_atomic_int(const char* path, int value); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* __CUTILS_FS_H */ 63 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/iosched_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_IOSCHED_POLICY_H 18 | #define __CUTILS_IOSCHED_POLICY_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | IoSchedClass_NONE, 26 | IoSchedClass_RT, 27 | IoSchedClass_BE, 28 | IoSchedClass_IDLE, 29 | } IoSchedClass; 30 | 31 | extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); 32 | extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __CUTILS_IOSCHED_POLICY_H */ 39 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/jstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_STRING16_H 18 | #define __CUTILS_STRING16_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef uint16_t char16_t; 28 | 29 | extern char * strndup16to8 (const char16_t* s, size_t n); 30 | extern size_t strnlen16to8 (const char16_t* s, size_t n); 31 | extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); 32 | 33 | extern char16_t * strdup8to16 (const char* s, size_t *out_len); 34 | extern size_t strlen8to16 (const char* utf8Str); 35 | extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); 36 | extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, 37 | size_t *out_len); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* __CUTILS_STRING16_H */ 44 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/klog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _CUTILS_KLOG_H_ 18 | #define _CUTILS_KLOG_H_ 19 | 20 | void klog_init(void); 21 | void klog_set_level(int level); 22 | void klog_close(void); 23 | void klog_write(int level, const char *fmt, ...) 24 | __attribute__ ((format(printf, 2, 3))); 25 | 26 | #define KLOG_ERROR(tag,x...) klog_write(3, "<3>" tag ": " x) 27 | #define KLOG_WARNING(tag,x...) klog_write(4, "<4>" tag ": " x) 28 | #define KLOG_NOTICE(tag,x...) klog_write(5, "<5>" tag ": " x) 29 | #define KLOG_INFO(tag,x...) klog_write(6, "<6>" tag ": " x) 30 | #define KLOG_DEBUG(tag,x...) klog_write(7, "<7>" tag ": " x) 31 | 32 | #define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _CUTILS_LIST_H_ 18 | #define _CUTILS_LIST_H_ 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif /* __cplusplus */ 25 | 26 | struct listnode 27 | { 28 | struct listnode *next; 29 | struct listnode *prev; 30 | }; 31 | 32 | #define node_to_item(node, container, member) \ 33 | (container *) (((char*) (node)) - offsetof(container, member)) 34 | 35 | #define list_declare(name) \ 36 | struct listnode name = { \ 37 | .next = &name, \ 38 | .prev = &name, \ 39 | } 40 | 41 | #define list_for_each(node, list) \ 42 | for (node = (list)->next; node != (list); node = node->next) 43 | 44 | #define list_for_each_reverse(node, list) \ 45 | for (node = (list)->prev; node != (list); node = node->prev) 46 | 47 | void list_init(struct listnode *list); 48 | void list_add_tail(struct listnode *list, struct listnode *item); 49 | void list_remove(struct listnode *item); 50 | 51 | #define list_empty(list) ((list) == (list)->next) 52 | #define list_head(list) ((list)->next) 53 | #define list_tail(list) ((list)->prev) 54 | 55 | #ifdef __cplusplus 56 | }; 57 | #endif /* __cplusplus */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/logd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ANDROID_CUTILS_LOGD_H 18 | #define _ANDROID_CUTILS_LOGD_H 19 | 20 | /* the stable/frozen log-related definitions have been 21 | * moved to this header, which is exposed by the NDK 22 | */ 23 | #include 24 | 25 | /* the rest is only used internally by the system */ 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #ifdef HAVE_PTHREADS 32 | #include 33 | #endif 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | int __android_log_bwrite(int32_t tag, const void *payload, size_t len); 42 | int __android_log_btwrite(int32_t tag, char type, const void *payload, 43 | size_t len); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* _LOGD_H */ 50 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_CUTILS_MEMORY_H 18 | #define ANDROID_CUTILS_MEMORY_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* size is given in bytes and must be multiple of 2 */ 28 | void android_memset16(uint16_t* dst, uint16_t value, size_t size); 29 | 30 | /* size is given in bytes and must be multiple of 4 */ 31 | void android_memset32(uint32_t* dst, uint32_t value, size_t size); 32 | 33 | #if !HAVE_STRLCPY 34 | /* Declaration of strlcpy() for platforms that don't already have it. */ 35 | size_t strlcpy(char *dst, const char *src, size_t size); 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif 41 | 42 | #endif // ANDROID_CUTILS_MEMORY_H 43 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_MISC_H 18 | #define __CUTILS_MISC_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* Load an entire file into a malloc'd chunk of memory 25 | * that is length_of_file + 1 (null terminator). If 26 | * sz is non-zero, return the size of the file via sz. 27 | * Returns 0 on failure. 28 | */ 29 | extern void *load_file(const char *fn, unsigned *sz); 30 | 31 | /* Connects your process to the system debugger daemon 32 | * so that on a crash it may be logged or interactively 33 | * debugged (depending on system settings). 34 | */ 35 | extern void debuggerd_connect(void); 36 | 37 | 38 | /* This is the range of UIDs (and GIDs) that are reserved 39 | * for assigning to applications. 40 | */ 41 | #define FIRST_APPLICATION_UID 10000 42 | #define LAST_APPLICATION_UID 99999 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* __CUTILS_MISC_H */ 49 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/multiuser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_MULTIUSER_H 18 | #define __CUTILS_MULTIUSER_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | // NOTE: keep in sync with android.os.UserId 27 | 28 | #define MULTIUSER_APP_PER_USER_RANGE 100000 29 | 30 | typedef uid_t userid_t; 31 | typedef uid_t appid_t; 32 | 33 | extern userid_t multiuser_get_user_id(uid_t uid); 34 | extern appid_t multiuser_get_app_id(uid_t uid); 35 | extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __CUTILS_MULTIUSER_H */ 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/native_handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef NATIVE_HANDLE_H_ 18 | #define NATIVE_HANDLE_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct native_handle 25 | { 26 | int version; /* sizeof(native_handle_t) */ 27 | int numFds; /* number of file-descriptors at &data[0] */ 28 | int numInts; /* number of ints at &data[numFds] */ 29 | int data[0]; /* numFds + numInts ints */ 30 | } native_handle_t; 31 | 32 | /* 33 | * native_handle_close 34 | * 35 | * closes the file descriptors contained in this native_handle_t 36 | * 37 | * return 0 on success, or a negative error code on failure 38 | * 39 | */ 40 | int native_handle_close(const native_handle_t* h); 41 | 42 | 43 | /* 44 | * native_handle_create 45 | * 46 | * creates a native_handle_t and initializes it. must be destroyed with 47 | * native_handle_delete(). 48 | * 49 | */ 50 | native_handle_t* native_handle_create(int numFds, int numInts); 51 | 52 | /* 53 | * native_handle_delete 54 | * 55 | * frees a native_handle_t allocated with native_handle_create(). 56 | * This ONLY frees the memory allocated for the native_handle_t, but doesn't 57 | * close the file descriptors; which can be achieved with native_handle_close(). 58 | * 59 | * return 0 on success, or a negative error code on failure 60 | * 61 | */ 62 | int native_handle_delete(native_handle_t* h); 63 | 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* NATIVE_HANDLE_H_ */ 70 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/open_memstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_OPEN_MEMSTREAM_H__ 18 | #define __CUTILS_OPEN_MEMSTREAM_H__ 19 | 20 | #include 21 | 22 | #ifndef HAVE_OPEN_MEMSTREAM 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | FILE* open_memstream(char** bufp, size_t* sizep); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /*!HAVE_OPEN_MEMSTREAM*/ 35 | 36 | #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ 37 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/partition_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_PARTITION_WIPED_H__ 18 | #define __CUTILS_PARTITION_WIPED_H__ 19 | 20 | __BEGIN_DECLS 21 | 22 | int partition_wiped(char *source); 23 | void erase_footer(const char *dev_path, long long size); 24 | 25 | __END_DECLS 26 | 27 | #endif /* __CUTILS_PARTITION_WIPED_H__ */ 28 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/process_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Gives the current process a name. 19 | */ 20 | 21 | #ifndef __PROCESS_NAME_H 22 | #define __PROCESS_NAME_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * Sets the current process name. 30 | * 31 | * Warning: This leaks a string every time you call it. Use judiciously! 32 | */ 33 | void set_process_name(const char* process_name); 34 | 35 | /** Gets the current process name. */ 36 | const char* get_process_name(void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __PROCESS_NAME_H */ 43 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_PROPERTIES_H 18 | #define __CUTILS_PROPERTIES_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* System properties are *small* name value pairs managed by the 25 | ** property service. If your data doesn't fit in the provided 26 | ** space it is not appropriate for a system property. 27 | ** 28 | ** WARNING: system/bionic/include/sys/system_properties.h also defines 29 | ** these, but with different names. (TODO: fix that) 30 | */ 31 | #define PROPERTY_KEY_MAX 32 32 | #define PROPERTY_VALUE_MAX 92 33 | 34 | /* property_get: returns the length of the value which will never be 35 | ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. 36 | ** (the length does not include the terminating zero). 37 | ** 38 | ** If the property read fails or returns an empty value, the default 39 | ** value is used (if nonnull). 40 | */ 41 | int property_get(const char *key, char *value, const char *default_value); 42 | 43 | /* property_set: returns 0 on success, < 0 on failure 44 | */ 45 | int property_set(const char *key, const char *value); 46 | 47 | int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); 48 | 49 | 50 | #ifdef HAVE_SYSTEM_PROPERTY_SERVER 51 | /* 52 | * We have an external property server instead of built-in libc support. 53 | * Used by the simulator. 54 | */ 55 | #define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop" 56 | 57 | enum { 58 | kSystemPropertyUnknown = 0, 59 | kSystemPropertyGet, 60 | kSystemPropertySet, 61 | kSystemPropertyList 62 | }; 63 | #endif /*HAVE_SYSTEM_PROPERTY_SERVER*/ 64 | 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/qsort_r_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Provides a portable version of qsort_r, called qsort_r_compat, which is a 19 | * reentrant variant of qsort that passes a user data pointer to its comparator. 20 | * This implementation follows the BSD parameter convention. 21 | */ 22 | 23 | #ifndef _LIBS_CUTILS_QSORT_R_COMPAT_H 24 | #define _LIBS_CUTILS_QSORT_R_COMPAT_H 25 | 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, 33 | int (*compar)(void*, const void* , const void* )); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // _LIBS_CUTILS_QSORT_R_COMPAT_H 40 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/qtaguid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_QTAGUID_H 18 | #define __CUTILS_QTAGUID_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* 29 | * Set tags (and owning UIDs) for network sockets. 30 | */ 31 | extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); 32 | 33 | /* 34 | * Untag a network socket before closing. 35 | */ 36 | extern int qtaguid_untagSocket(int sockfd); 37 | 38 | /* 39 | * For the given uid, switch counter sets. 40 | * The kernel only keeps a limited number of sets. 41 | * 2 for now. 42 | */ 43 | extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid); 44 | 45 | /* 46 | * Delete all tag info that relates to the given tag an uid. 47 | * If the tag is 0, then ALL info about the uid is freeded. 48 | * The delete data also affects active tagged socketd, which are 49 | * then untagged. 50 | * The calling process can only operate on its own tags. 51 | * Unless it is part of the happy AID_NET_BW_ACCT group. 52 | * In which case it can clobber everything. 53 | */ 54 | extern int qtaguid_deleteTagData(int tag, uid_t uid); 55 | 56 | /* 57 | * Enable/disable qtaguid functionnality at a lower level. 58 | * When pacified, the kernel will accept commands but do nothing. 59 | */ 60 | extern int qtaguid_setPacifier(int on); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __CUTILS_QTAG_UID_H */ 67 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/record_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * A simple utility for reading fixed records out of a stream fd 19 | */ 20 | 21 | #ifndef _CUTILS_RECORD_STREAM_H 22 | #define _CUTILS_RECORD_STREAM_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | 29 | typedef struct RecordStream RecordStream; 30 | 31 | extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); 32 | extern void record_stream_free(RecordStream *p_rs); 33 | 34 | extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, 35 | size_t *p_outRecordLen); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | 42 | #endif /*_CUTILS_RECORD_STREAM_H*/ 43 | 44 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/sched_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_SCHED_POLICY_H 18 | #define __CUTILS_SCHED_POLICY_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ 25 | typedef enum { 26 | SP_DEFAULT = -1, 27 | SP_BACKGROUND = 0, 28 | SP_FOREGROUND = 1, 29 | SP_SYSTEM = 2, // can't be used with set_sched_policy() 30 | SP_AUDIO_APP = 3, 31 | SP_AUDIO_SYS = 4, 32 | SP_CNT, 33 | SP_MAX = SP_CNT - 1, 34 | SP_SYSTEM_DEFAULT = SP_FOREGROUND, 35 | } SchedPolicy; 36 | 37 | /* Assign thread tid to the cgroup associated with the specified policy. 38 | * If the thread is a thread group leader, that is it's gettid() == getpid(), 39 | * then the other threads in the same thread group are _not_ affected. 40 | * On platforms which support gettid(), zero tid means current thread. 41 | * Return value: 0 for success, or -errno for error. 42 | */ 43 | extern int set_sched_policy(int tid, SchedPolicy policy); 44 | 45 | /* Return the policy associated with the cgroup of thread tid via policy pointer. 46 | * On platforms which support gettid(), zero tid means current thread. 47 | * Return value: 0 for success, or -1 for error and set errno. 48 | */ 49 | extern int get_sched_policy(int tid, SchedPolicy *policy); 50 | 51 | /* Return a displayable string corresponding to policy. 52 | * Return value: non-NULL NUL-terminated name of unspecified length; 53 | * the caller is responsible for displaying the useful part of the string. 54 | */ 55 | extern const char *get_sched_policy_name(SchedPolicy policy); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* __CUTILS_SCHED_POLICY_H */ 62 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/str_parms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_STR_PARMS_H 18 | #define __CUTILS_STR_PARMS_H 19 | 20 | #include 21 | 22 | struct str_parms; 23 | 24 | struct str_parms *str_parms_create(void); 25 | struct str_parms *str_parms_create_str(const char *_string); 26 | void str_parms_destroy(struct str_parms *str_parms); 27 | 28 | void str_parms_del(struct str_parms *str_parms, const char *key); 29 | 30 | int str_parms_add_str(struct str_parms *str_parms, const char *key, 31 | const char *value); 32 | int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); 33 | 34 | int str_parms_add_float(struct str_parms *str_parms, const char *key, 35 | float value); 36 | 37 | int str_parms_get_str(struct str_parms *str_parms, const char *key, 38 | char *out_val, int len); 39 | int str_parms_get_int(struct str_parms *str_parms, const char *key, 40 | int *out_val); 41 | int str_parms_get_float(struct str_parms *str_parms, const char *key, 42 | float *out_val); 43 | 44 | char *str_parms_to_str(struct str_parms *str_parms); 45 | 46 | /* debug */ 47 | void str_parms_dump(struct str_parms *str_parms); 48 | 49 | #endif /* __CUTILS_STR_PARMS_H */ 50 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/tztime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _CUTILS_TZTIME_H 18 | #define _CUTILS_TZTIME_H 19 | 20 | // TODO: fix both callers to just include themselves. 21 | #include 22 | 23 | #endif /* __CUTILS_TZTIME_H */ 24 | 25 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/uevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_UEVENT_H 18 | #define __CUTILS_UEVENT_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | int uevent_open_socket(int buf_sz, bool passcred); 28 | ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); 29 | ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* __CUTILS_UEVENT_H */ 36 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // 18 | // implementation of sys/uio.h for platforms that don't have it (Win32) 19 | // 20 | #ifndef _LIBS_CUTILS_UIO_H 21 | #define _LIBS_CUTILS_UIO_H 22 | 23 | #ifdef HAVE_SYS_UIO_H 24 | #include 25 | #else 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include 32 | 33 | struct iovec { 34 | const void* iov_base; 35 | size_t iov_len; 36 | }; 37 | 38 | extern int readv( int fd, struct iovec* vecs, int count ); 39 | extern int writev( int fd, const struct iovec* vecs, int count ); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* !HAVE_SYS_UIO_H */ 46 | 47 | #endif /* _LIBS_UTILS_UIO_H */ 48 | 49 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/cutils/zygote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_ZYGOTE_H 18 | #define __CUTILS_ZYGOTE_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | int zygote_run_oneshot(int sendStdio, int argc, const char **argv); 25 | int zygote_run(int argc, const char **argv); 26 | int zygote_run_wait(int argc, const char **argv, void (*post_run_func)(int)); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __CUTILS_ZYGOTE_H */ 33 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/mincrypt/rsa.h: -------------------------------------------------------------------------------- 1 | /* rsa.h 2 | ** 3 | ** Copyright 2008, The Android Open Source Project 4 | ** 5 | ** Redistribution and use in source and binary forms, with or without 6 | ** modification, are permitted provided that the following conditions are met: 7 | ** * Redistributions of source code must retain the above copyright 8 | ** notice, this list of conditions and the following disclaimer. 9 | ** * Redistributions in binary form must reproduce the above copyright 10 | ** notice, this list of conditions and the following disclaimer in the 11 | ** documentation and/or other materials provided with the distribution. 12 | ** * Neither the name of Google Inc. nor the names of its contributors may 13 | ** be used to endorse or promote products derived from this software 14 | ** without specific prior written permission. 15 | ** 16 | ** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 17 | ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | ** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _EMBEDDED_RSA_H_ 29 | #define _EMBEDDED_RSA_H_ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #define RSANUMBYTES 256 /* 2048 bit key length */ 38 | #define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t)) 39 | 40 | typedef struct RSAPublicKey { 41 | int len; /* Length of n[] in number of uint32_t */ 42 | uint32_t n0inv; /* -1 / n[0] mod 2^32 */ 43 | uint32_t n[RSANUMWORDS]; /* modulus as little endian array */ 44 | uint32_t rr[RSANUMWORDS]; /* R^2 as little endian array */ 45 | int exponent; /* 3 or 65537 */ 46 | } RSAPublicKey; 47 | 48 | int RSA_verify(const RSAPublicKey *key, 49 | const uint8_t* signature, 50 | const int len, 51 | const uint8_t* sha); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/mincrypt/sha.h: -------------------------------------------------------------------------------- 1 | /* sha.h 2 | ** 3 | ** Copyright 2008, The Android Open Source Project 4 | ** 5 | ** Redistribution and use in source and binary forms, with or without 6 | ** modification, are permitted provided that the following conditions are met: 7 | ** * Redistributions of source code must retain the above copyright 8 | ** notice, this list of conditions and the following disclaimer. 9 | ** * Redistributions in binary form must reproduce the above copyright 10 | ** notice, this list of conditions and the following disclaimer in the 11 | ** documentation and/or other materials provided with the distribution. 12 | ** * Neither the name of Google Inc. nor the names of its contributors may 13 | ** be used to endorse or promote products derived from this software 14 | ** without specific prior written permission. 15 | ** 16 | ** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 17 | ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | ** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef _EMBEDDED_SHA_H_ 29 | #define _EMBEDDED_SHA_H_ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef struct SHA_CTX { 38 | uint64_t count; 39 | uint32_t state[5]; 40 | #if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) 41 | union { 42 | uint8_t b[64]; 43 | uint32_t w[16]; 44 | } buf; 45 | #else 46 | uint8_t buf[64]; 47 | #endif 48 | } SHA_CTX; 49 | 50 | void SHA_init(SHA_CTX* ctx); 51 | void SHA_update(SHA_CTX* ctx, const void* data, int len); 52 | const uint8_t* SHA_final(SHA_CTX* ctx); 53 | 54 | /* Convenience method. Returns digest parameter value. */ 55 | const uint8_t* SHA(const void* data, int len, uint8_t* digest); 56 | 57 | #define SHA_DIGEST_SIZE 20 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/include/zipfile/zipfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ZIPFILE_ZIPFILE_H 18 | #define _ZIPFILE_ZIPFILE_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | typedef void* zipfile_t; 27 | typedef void* zipentry_t; 28 | 29 | // Provide a buffer. Returns NULL on failure. 30 | zipfile_t init_zipfile(const void* data, size_t size); 31 | 32 | // Release the zipfile resources. 33 | void release_zipfile(zipfile_t file); 34 | 35 | // Get a named entry object. Returns NULL if it doesn't exist 36 | // or if we won't be able to decompress it. The zipentry_t is 37 | // freed by release_zipfile() 38 | zipentry_t lookup_zipentry(zipfile_t file, const char* entryName); 39 | 40 | // Return the size of the entry. 41 | size_t get_zipentry_size(zipentry_t entry); 42 | 43 | // return the filename of this entry, you own the memory returned 44 | char* get_zipentry_name(zipentry_t entry); 45 | 46 | // The buffer must be 1.001 times the buffer size returned 47 | // by get_zipentry_size. Returns nonzero on failure. 48 | int decompress_zipentry(zipentry_t entry, void* buf, int bufsize); 49 | 50 | // iterate through the entries in the zip file. pass a pointer to 51 | // a void* initialized to NULL to start. Returns NULL when done 52 | zipentry_t iterate_zipfile(zipfile_t file, void** cookie); 53 | 54 | #ifdef __cplusplus 55 | } // extern "C" 56 | #endif 57 | 58 | #endif // _ZIPFILE_ZIPFILE_H 59 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/ashmem-dev.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Implementation of the user-space ashmem API for devices, which have our 19 | * ashmem-enabled kernel. See ashmem-sim.c for the "fake" tmp-based version, 20 | * used by the simulator. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #define ASHMEM_DEVICE "/dev/ashmem" 34 | 35 | /* 36 | * ashmem_create_region - creates a new ashmem region and returns the file 37 | * descriptor, or <0 on error 38 | * 39 | * `name' is an optional label to give the region (visible in /proc/pid/maps) 40 | * `size' is the size of the region, in page-aligned bytes 41 | */ 42 | int ashmem_create_region(const char *name, size_t size) 43 | { 44 | int fd, ret; 45 | 46 | fd = open(ASHMEM_DEVICE, O_RDWR); 47 | if (fd < 0) 48 | return fd; 49 | 50 | if (name) { 51 | char buf[ASHMEM_NAME_LEN]; 52 | 53 | strlcpy(buf, name, sizeof(buf)); 54 | ret = ioctl(fd, ASHMEM_SET_NAME, buf); 55 | if (ret < 0) 56 | goto error; 57 | } 58 | 59 | ret = ioctl(fd, ASHMEM_SET_SIZE, size); 60 | if (ret < 0) 61 | goto error; 62 | 63 | return fd; 64 | 65 | error: 66 | close(fd); 67 | return ret; 68 | } 69 | 70 | int ashmem_set_prot_region(int fd, int prot) 71 | { 72 | return ioctl(fd, ASHMEM_SET_PROT_MASK, prot); 73 | } 74 | 75 | int ashmem_pin_region(int fd, size_t offset, size_t len) 76 | { 77 | struct ashmem_pin pin = { offset, len }; 78 | return ioctl(fd, ASHMEM_PIN, &pin); 79 | } 80 | 81 | int ashmem_unpin_region(int fd, size_t offset, size_t len) 82 | { 83 | struct ashmem_pin pin = { offset, len }; 84 | return ioctl(fd, ASHMEM_UNPIN, &pin); 85 | } 86 | 87 | int ashmem_get_size_region(int fd) 88 | { 89 | return ioctl(fd, ASHMEM_GET_SIZE, NULL); 90 | } 91 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/atomic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define ANDROID_ATOMIC_INLINE 18 | 19 | #include 20 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/dlmalloc_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../../../bionic/libc/bionic/dlmalloc.h" 18 | #include "cutils/log.h" 19 | 20 | /* 21 | * Stubs for functions defined in bionic/libc/bionic/dlmalloc.c. These 22 | * are used in host builds, as the host libc will not contain these 23 | * functions. 24 | */ 25 | void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), 26 | void* arg) 27 | { 28 | ALOGW("Called host unimplemented stub: dlmalloc_inspect_all"); 29 | } 30 | 31 | int dlmalloc_trim(size_t unused) 32 | { 33 | ALOGW("Called host unimplemented stub: dlmalloc_trim"); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/iosched_policy.c: -------------------------------------------------------------------------------- 1 | 2 | /* libs/cutils/iosched_policy.c 3 | ** 4 | ** Copyright 2007, The Android Open Source Project 5 | ** 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); 7 | ** you may not use this file except in compliance with the License. 8 | ** You may obtain a copy of the License at 9 | ** 10 | ** http://www.apache.org/licenses/LICENSE-2.0 11 | ** 12 | ** Unless required by applicable law or agreed to in writing, software 13 | ** distributed under the License is distributed on an "AS IS" BASIS, 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | ** See the License for the specific language governing permissions and 16 | ** limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifdef HAVE_SCHED_H 27 | 28 | #include 29 | 30 | extern int ioprio_set(int which, int who, int ioprio); 31 | 32 | enum { 33 | WHO_PROCESS = 1, 34 | WHO_PGRP, 35 | WHO_USER, 36 | }; 37 | 38 | #define CLASS_SHIFT 13 39 | #define IOPRIO_NORM 4 40 | 41 | int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio) { 42 | #ifdef HAVE_ANDROID_OS 43 | if (ioprio_set(WHO_PROCESS, pid, ioprio | (clazz << CLASS_SHIFT))) { 44 | return -1; 45 | } 46 | #endif 47 | return 0; 48 | } 49 | 50 | int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio) { 51 | #ifdef HAVE_ANDROID_OS 52 | int rc; 53 | 54 | if ((rc = ioprio_get(WHO_PROCESS, pid)) < 0) { 55 | return -1; 56 | } 57 | 58 | *clazz = (rc >> CLASS_SHIFT); 59 | *ioprio = (rc & 0xff); 60 | #else 61 | *clazz = IoSchedClass_NONE; 62 | *ioprio = 0; 63 | #endif 64 | return 0; 65 | } 66 | 67 | #endif /* HAVE_SCHED_H */ 68 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/klog.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | static int klog_fd = -1; 29 | static int klog_level = KLOG_DEFAULT_LEVEL; 30 | 31 | void klog_set_level(int level) { 32 | klog_level = level; 33 | } 34 | 35 | void klog_init(void) 36 | { 37 | static const char *name = "/dev/__kmsg__"; 38 | if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) { 39 | klog_fd = open(name, O_WRONLY); 40 | fcntl(klog_fd, F_SETFD, FD_CLOEXEC); 41 | unlink(name); 42 | } 43 | } 44 | 45 | #define LOG_BUF_MAX 512 46 | 47 | void klog_write(int level, const char *fmt, ...) 48 | { 49 | char buf[LOG_BUF_MAX]; 50 | va_list ap; 51 | 52 | if (level > klog_level) return; 53 | if (klog_fd < 0) return; 54 | 55 | va_start(ap, fmt); 56 | vsnprintf(buf, LOG_BUF_MAX, fmt, ap); 57 | buf[LOG_BUF_MAX - 1] = 0; 58 | va_end(ap); 59 | write(klog_fd, buf, strlen(buf)); 60 | } 61 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | void list_init(struct listnode *node) 20 | { 21 | node->next = node; 22 | node->prev = node; 23 | } 24 | 25 | void list_add_tail(struct listnode *head, struct listnode *item) 26 | { 27 | item->next = head; 28 | item->prev = head->prev; 29 | head->prev->next = item; 30 | head->prev = item; 31 | } 32 | 33 | void list_remove(struct listnode *item) 34 | { 35 | item->next->prev = item->prev; 36 | item->prev->next = item->next; 37 | } 38 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/load_file.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/load_file.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void *load_file(const char *fn, unsigned *_sz) 23 | { 24 | char *data; 25 | int sz; 26 | int fd; 27 | 28 | data = 0; 29 | fd = open(fn, O_RDONLY); 30 | if(fd < 0) return 0; 31 | 32 | sz = lseek(fd, 0, SEEK_END); 33 | if(sz < 0) goto oops; 34 | 35 | if(lseek(fd, 0, SEEK_SET) != 0) goto oops; 36 | 37 | data = (char*) malloc(sz + 1); 38 | if(data == 0) goto oops; 39 | 40 | if(read(fd, data, sz) != sz) goto oops; 41 | close(fd); 42 | data[sz] = 0; 43 | 44 | if(_sz) *_sz = sz; 45 | return data; 46 | 47 | oops: 48 | close(fd); 49 | if(data != 0) free(data); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/loghack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This is a temporary hack to enable logging from cutils. 19 | */ 20 | 21 | #ifndef _CUTILS_LOGHACK_H 22 | #define _CUTILS_LOGHACK_H 23 | 24 | #ifdef HAVE_ANDROID_OS 25 | #include 26 | #else 27 | #include 28 | #define ALOG(level, ...) \ 29 | ((void)printf("cutils:" level "/" LOG_TAG ": " __VA_ARGS__)) 30 | #define ALOGV(...) ALOG("V", __VA_ARGS__) 31 | #define ALOGD(...) ALOG("D", __VA_ARGS__) 32 | #define ALOGI(...) ALOG("I", __VA_ARGS__) 33 | #define ALOGW(...) ALOG("W", __VA_ARGS__) 34 | #define ALOGE(...) ALOG("E", __VA_ARGS__) 35 | #define LOG_ALWAYS_FATAL(...) do { ALOGE(__VA_ARGS__); exit(1); } while (0) 36 | #endif 37 | 38 | #endif // _CUTILS_LOGHACK_H 39 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/multiuser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | userid_t multiuser_get_user_id(uid_t uid) { 20 | return uid / MULTIUSER_APP_PER_USER_RANGE; 21 | } 22 | 23 | appid_t multiuser_get_app_id(uid_t uid) { 24 | return uid % MULTIUSER_APP_PER_USER_RANGE; 25 | } 26 | 27 | uid_t multiuser_get_uid(userid_t userId, appid_t appId) { 28 | return userId * MULTIUSER_APP_PER_USER_RANGE + (appId % MULTIUSER_APP_PER_USER_RANGE); 29 | } 30 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/native_handle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "NativeHandle" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | native_handle_t* native_handle_create(int numFds, int numInts) 29 | { 30 | native_handle_t* h = malloc( 31 | sizeof(native_handle_t) + sizeof(int)*(numFds+numInts)); 32 | 33 | h->version = sizeof(native_handle_t); 34 | h->numFds = numFds; 35 | h->numInts = numInts; 36 | return h; 37 | } 38 | 39 | int native_handle_delete(native_handle_t* h) 40 | { 41 | if (h) { 42 | if (h->version != sizeof(native_handle_t)) 43 | return -EINVAL; 44 | free(h); 45 | } 46 | return 0; 47 | } 48 | 49 | int native_handle_close(const native_handle_t* h) 50 | { 51 | if (h->version != sizeof(native_handle_t)) 52 | return -EINVAL; 53 | 54 | const int numFds = h->numFds; 55 | int i; 56 | for (i=0 ; idata[i]); 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/partition_utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include /* for BLKGETSIZE */ 23 | #include 24 | 25 | static int only_one_char(char *buf, int len, char c) 26 | { 27 | int i, ret; 28 | 29 | ret = 1; 30 | for (i=0; i 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifndef HAVE_WINSOCK 27 | #include 28 | #include 29 | #include 30 | #include 31 | #endif 32 | 33 | #define LISTEN_BACKLOG 4 34 | 35 | /* open listen() port on any interface */ 36 | int socket_inaddr_any_server(int port, int type) 37 | { 38 | struct sockaddr_in addr; 39 | size_t alen; 40 | int s, n; 41 | 42 | memset(&addr, 0, sizeof(addr)); 43 | addr.sin_family = AF_INET; 44 | addr.sin_port = htons(port); 45 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 46 | 47 | s = socket(AF_INET, type, 0); 48 | if(s < 0) return -1; 49 | 50 | n = 1; 51 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); 52 | 53 | if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 54 | close(s); 55 | return -1; 56 | } 57 | 58 | if (type == SOCK_STREAM) { 59 | int ret; 60 | 61 | ret = listen(s, LISTEN_BACKLOG); 62 | 63 | if (ret < 0) { 64 | close(s); 65 | return -1; 66 | } 67 | } 68 | 69 | return s; 70 | } 71 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/socket_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __SOCKET_LOCAL_H 18 | #define __SOCKET_LOCAL_H 19 | 20 | #define FILESYSTEM_SOCKET_PREFIX "/tmp/" 21 | #define ANDROID_RESERVED_SOCKET_PREFIX "/dev/socket/" 22 | 23 | /* 24 | * Set up a given sockaddr_un, to have it refer to the given 25 | * name in the given namespace. The namespace must be one 26 | * of ANDROID_SOCKET_NAMESPACE_ABSTRACT, 27 | * ANDROID_SOCKET_NAMESPACE_RESERVED, or 28 | * ANDROID_SOCKET_NAMESPACE_FILESYSTEM. Upon success, 29 | * the pointed at sockaddr_un is filled in and the pointed at 30 | * socklen_t is set to indicate the final length. This function 31 | * will fail if the namespace is invalid (not one of the indicated 32 | * constants) or if the name is too long. 33 | * 34 | * @return 0 on success or -1 on failure 35 | */ 36 | int socket_make_sockaddr_un(const char *name, int namespaceId, 37 | struct sockaddr_un *p_addr, socklen_t *alen); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/socket_loopback_client.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/socket_loopback_client.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifndef HAVE_WINSOCK 27 | #include 28 | #include 29 | #include 30 | #include 31 | #endif 32 | 33 | /* Connect to port on the loopback IP interface. type is 34 | * SOCK_STREAM or SOCK_DGRAM. 35 | * return is a file descriptor or -1 on error 36 | */ 37 | int socket_loopback_client(int port, int type) 38 | { 39 | struct sockaddr_in addr; 40 | socklen_t alen; 41 | int s; 42 | 43 | memset(&addr, 0, sizeof(addr)); 44 | addr.sin_family = AF_INET; 45 | addr.sin_port = htons(port); 46 | addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 47 | 48 | s = socket(AF_INET, type, 0); 49 | if(s < 0) return -1; 50 | 51 | if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 52 | close(s); 53 | return -1; 54 | } 55 | 56 | return s; 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/socket_loopback_server.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/socket_loopback_server.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #define LISTEN_BACKLOG 4 27 | 28 | #ifndef HAVE_WINSOCK 29 | #include 30 | #include 31 | #include 32 | #include 33 | #endif 34 | 35 | /* open listen() port on loopback interface */ 36 | int socket_loopback_server(int port, int type) 37 | { 38 | struct sockaddr_in addr; 39 | size_t alen; 40 | int s, n; 41 | 42 | memset(&addr, 0, sizeof(addr)); 43 | addr.sin_family = AF_INET; 44 | addr.sin_port = htons(port); 45 | addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 46 | 47 | s = socket(AF_INET, type, 0); 48 | if(s < 0) return -1; 49 | 50 | n = 1; 51 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)); 52 | 53 | if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 54 | close(s); 55 | return -1; 56 | } 57 | 58 | if (type == SOCK_STREAM) { 59 | int ret; 60 | 61 | ret = listen(s, LISTEN_BACKLOG); 62 | 63 | if (ret < 0) { 64 | close(s); 65 | return -1; 66 | } 67 | } 68 | 69 | return s; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/socket_network_client.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/socket_network_client.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifndef HAVE_WINSOCK 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #endif 33 | 34 | 35 | /* Connect to port on the IP interface. type is 36 | * SOCK_STREAM or SOCK_DGRAM. 37 | * return is a file descriptor or -1 on error 38 | */ 39 | int socket_network_client(const char *host, int port, int type) 40 | { 41 | struct hostent *hp; 42 | struct sockaddr_in addr; 43 | socklen_t alen; 44 | int s; 45 | 46 | hp = gethostbyname(host); 47 | if(hp == 0) return -1; 48 | 49 | memset(&addr, 0, sizeof(addr)); 50 | addr.sin_family = hp->h_addrtype; 51 | addr.sin_port = htons(port); 52 | memcpy(&addr.sin_addr, hp->h_addr, hp->h_length); 53 | 54 | s = socket(hp->h_addrtype, type, 0); 55 | if(s < 0) return -1; 56 | 57 | if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 58 | close(s); 59 | return -1; 60 | } 61 | 62 | return s; 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/sockets.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef HAVE_ANDROID_OS 21 | /* For the socket trust (credentials) check */ 22 | #include 23 | #endif 24 | 25 | bool socket_peer_is_trusted(int fd) 26 | { 27 | #ifdef HAVE_ANDROID_OS 28 | struct ucred cr; 29 | socklen_t len = sizeof(cr); 30 | int n = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &len); 31 | 32 | if (n != 0) { 33 | ALOGE("could not get socket credentials: %s\n", strerror(errno)); 34 | return false; 35 | } 36 | 37 | if ((cr.uid != AID_ROOT) && (cr.uid != AID_SHELL)) { 38 | ALOGE("untrusted userid on other end of socket: userid %d\n", cr.uid); 39 | return false; 40 | } 41 | #endif 42 | 43 | return true; 44 | } 45 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libcutils/uio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef HAVE_SYS_UIO_H 18 | 19 | #include 20 | #include 21 | 22 | int readv( int fd, struct iovec* vecs, int count ) 23 | { 24 | int total = 0; 25 | 26 | for ( ; count > 0; count--, vecs++ ) { 27 | const char* buf = vecs->iov_base; 28 | int len = vecs->iov_len; 29 | 30 | while (len > 0) { 31 | int ret = read( fd, buf, len ); 32 | if (ret < 0) { 33 | if (total == 0) 34 | total = -1; 35 | goto Exit; 36 | } 37 | if (ret == 0) 38 | goto Exit; 39 | 40 | total += ret; 41 | buf += ret; 42 | len -= ret; 43 | } 44 | } 45 | Exit: 46 | return total; 47 | } 48 | 49 | int writev( int fd, const struct iovec* vecs, int count ) 50 | { 51 | int total = 0; 52 | 53 | for ( ; count > 0; count--, vecs++ ) { 54 | const char* buf = (const char*)vecs->iov_base; 55 | int len = (int)vecs->iov_len; 56 | 57 | while (len > 0) { 58 | int ret = write( fd, buf, len ); 59 | if (ret < 0) { 60 | if (total == 0) 61 | total = -1; 62 | goto Exit; 63 | } 64 | if (ret == 0) 65 | goto Exit; 66 | 67 | total += ret; 68 | buf += ret; 69 | len -= ret; 70 | } 71 | } 72 | Exit: 73 | return total; 74 | } 75 | 76 | #endif /* !HAVE_SYS_UIO_H */ 77 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/output_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _OUTPUT_FILE_H_ 18 | #define _OUTPUT_FILE_H_ 19 | 20 | #include 21 | 22 | struct output_file; 23 | 24 | struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t len, 25 | int gz, int sparse, int chunks, int crc); 26 | struct output_file *output_file_open_callback(int (*write)(void *, const void *, int), 27 | void *priv, unsigned int block_size, int64_t len, int gz, int sparse, 28 | int chunks, int crc); 29 | int write_data_chunk(struct output_file *out, unsigned int len, void *data); 30 | int write_fill_chunk(struct output_file *out, unsigned int len, 31 | uint32_t fill_val); 32 | int write_file_chunk(struct output_file *out, unsigned int len, 33 | const char *file, int64_t offset); 34 | int write_fd_chunk(struct output_file *out, unsigned int len, 35 | int fd, int64_t offset); 36 | int write_skip_chunk(struct output_file *out, int64_t len); 37 | void output_file_close(struct output_file *out); 38 | 39 | int read_all(int fd, void *buf, size_t len); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/simg2img.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifndef O_BINARY 30 | #define O_BINARY 0 31 | #endif 32 | 33 | void usage() 34 | { 35 | fprintf(stderr, "Usage: simg2img \n"); 36 | } 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | int in; 41 | int out; 42 | int i; 43 | int ret; 44 | struct sparse_file *s; 45 | 46 | if (argc < 3) { 47 | usage(); 48 | exit(-1); 49 | } 50 | 51 | out = open(argv[argc - 1], O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); 52 | if (out < 0) { 53 | fprintf(stderr, "Cannot open output file %s\n", argv[argc - 1]); 54 | exit(-1); 55 | } 56 | 57 | for (i = 1; i < argc - 1; i++) { 58 | if (strcmp(argv[i], "-") == 0) { 59 | in = STDIN_FILENO; 60 | } else { 61 | in = open(argv[i], O_RDONLY | O_BINARY); 62 | if (in < 0) { 63 | fprintf(stderr, "Cannot open input file %s\n", argv[i]); 64 | exit(-1); 65 | } 66 | } 67 | 68 | s = sparse_file_import(in, true, false); 69 | if (!s) { 70 | fprintf(stderr, "Failed to read sparse file\n"); 71 | exit(-1); 72 | } 73 | 74 | lseek(out, SEEK_SET, 0); 75 | 76 | ret = sparse_file_write(s, out, false, false, false); 77 | if (ret < 0) { 78 | fprintf(stderr, "Cannot write output file\n"); 79 | exit(-1); 80 | } 81 | sparse_file_destroy(s); 82 | close(in); 83 | } 84 | 85 | close(out); 86 | 87 | exit(0); 88 | } 89 | 90 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/sparse_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | uint32_t sparse_crc32(uint32_t crc, const void *buf, size_t size); 20 | 21 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/sparse_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBSPARSE_SPARSE_DEFS_ 18 | #define _LIBSPARSE_SPARSE_DEFS_ 19 | 20 | #include 21 | #include 22 | 23 | #define __le64 u64 24 | #define __le32 u32 25 | #define __le16 u16 26 | 27 | #define __be64 u64 28 | #define __be32 u32 29 | #define __be16 u16 30 | 31 | #define __u64 u64 32 | #define __u32 u32 33 | #define __u16 u16 34 | #define __u8 u8 35 | 36 | typedef unsigned long long u64; 37 | typedef signed long long s64; 38 | typedef unsigned int u32; 39 | typedef unsigned short int u16; 40 | typedef unsigned char u8; 41 | 42 | #define DIV_ROUND_UP(x, y) (((x) + (y) - 1)/(y)) 43 | #define ALIGN(x, y) ((y) * DIV_ROUND_UP((x), (y))) 44 | #define ALIGN_DOWN(x, y) ((y) * ((x) / (y))) 45 | 46 | #define error(fmt, args...) do { fprintf(stderr, "error: %s: " fmt "\n", __func__, ## args); } while (0) 47 | #define error_errno(s, args...) error(s ": %s", ##args, strerror(errno)) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/sparse_err.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | void sparse_default_print(const char *fmt, ...) 24 | { 25 | va_list argp; 26 | 27 | va_start(argp, fmt); 28 | vfprintf(stderr, fmt, argp); 29 | va_end(argp); 30 | } 31 | 32 | void (*sparse_print_error)(const char *fmt, ...) = sparse_default_print; 33 | void (*sparse_print_verbose)(const char *fmt, ...) = sparse_default_print; 34 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/sparse_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBSPARSE_SPARSE_FILE_H_ 18 | #define _LIBSPARSE_SPARSE_FILE_H_ 19 | 20 | #include 21 | 22 | struct sparse_file { 23 | unsigned int block_size; 24 | int64_t len; 25 | bool verbose; 26 | 27 | struct backed_block_list *backed_block_list; 28 | struct output_file *out; 29 | }; 30 | 31 | 32 | #endif /* _LIBSPARSE_SPARSE_FILE_H_ */ 33 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libsparse/sparse_format.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBSPARSE_SPARSE_FORMAT_H_ 18 | #define _LIBSPARSE_SPARSE_FORMAT_H_ 19 | #include "sparse_defs.h" 20 | 21 | typedef struct sparse_header { 22 | __le32 magic; /* 0xed26ff3a */ 23 | __le16 major_version; /* (0x1) - reject images with higher major versions */ 24 | __le16 minor_version; /* (0x0) - allow images with higer minor versions */ 25 | __le16 file_hdr_sz; /* 28 bytes for first revision of the file format */ 26 | __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */ 27 | __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */ 28 | __le32 total_blks; /* total blocks in the non-sparse output image */ 29 | __le32 total_chunks; /* total chunks in the sparse input image */ 30 | __le32 image_checksum; /* CRC32 checksum of the original data, counting "don't care" */ 31 | /* as 0. Standard 802.3 polynomial, use a Public Domain */ 32 | /* table implementation */ 33 | } sparse_header_t; 34 | 35 | #define SPARSE_HEADER_MAGIC 0xed26ff3a 36 | 37 | #define CHUNK_TYPE_RAW 0xCAC1 38 | #define CHUNK_TYPE_FILL 0xCAC2 39 | #define CHUNK_TYPE_DONT_CARE 0xCAC3 40 | #define CHUNK_TYPE_CRC32 0xCAC4 41 | 42 | typedef struct chunk_header { 43 | __le16 chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */ 44 | __le16 reserved1; 45 | __le32 chunk_sz; /* in blocks in output image */ 46 | __le32 total_sz; /* in bytes of chunk input file including chunk header and data */ 47 | } chunk_header_t; 48 | 49 | /* Following a Raw or Fill or CRC32 chunk is data. 50 | * For a Raw chunk, it's the data in chunk_sz * blk_sz. 51 | * For a Fill chunk, it's 4 bytes of the fill data. 52 | * For a CRC32 chunk, it's 4 bytes of CRC32 53 | */ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /android-tools-4.2.2/core/libzipfile/private.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIVATE_H 2 | #define PRIVATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | typedef struct Zipentry { 11 | unsigned long fileNameLength; 12 | const unsigned char* fileName; 13 | unsigned short compressionMethod; 14 | unsigned int uncompressedSize; 15 | unsigned int compressedSize; 16 | const unsigned char* data; 17 | 18 | struct Zipentry* next; 19 | } Zipentry; 20 | 21 | typedef struct Zipfile 22 | { 23 | const unsigned char *buf; 24 | ssize_t bufsize; 25 | 26 | // Central directory 27 | unsigned short disknum; //mDiskNumber; 28 | unsigned short diskWithCentralDir; //mDiskWithCentralDir; 29 | unsigned short entryCount; //mNumEntries; 30 | unsigned short totalEntryCount; //mTotalNumEntries; 31 | unsigned int centralDirSize; //mCentralDirSize; 32 | unsigned int centralDirOffest; // offset from first disk //mCentralDirOffset; 33 | unsigned short commentLen; //mCommentLen; 34 | const unsigned char* comment; //mComment; 35 | 36 | Zipentry* entries; 37 | } Zipfile; 38 | 39 | int read_central_dir(Zipfile* file); 40 | 41 | unsigned int read_le_int(const unsigned char* buf); 42 | unsigned int read_le_short(const unsigned char* buf); 43 | 44 | #endif // PRIVATE_H 45 | 46 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/README.source: -------------------------------------------------------------------------------- 1 | android-tools for Debian 2 | ------------------------ 3 | 4 | The upstream tarball is based of these upstream Android git repos: 5 | git clone https://android.googlesource.com/platform/system/core 6 | git clone https://android.googlesource.com/platform/system/extras 7 | 8 | with unneeded files removed. 9 | 10 | The debian/create-snapshot script may be used to generate an 11 | android-tools.tar.xz from the latest upstream; see this script for a list of 12 | files to copy from upstream into the tarball. 13 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/adb-completion: -------------------------------------------------------------------------------- 1 | _adb() 2 | { 3 | local cur prev opts 4 | COMPREPLY=() 5 | cur="${COMP_WORDS[COMP_CWORD]}" 6 | prev="${COMP_WORDS[COMP_CWORD-1]}" 7 | opts="shell push pull reboot reboot-bootloader forward logcat devices kill-server root remount" 8 | 9 | case "$prev" in 10 | shell | pull | reboot-bootloader | logcat | devices | kill-server | root | remount) 11 | COMPREPLY=() 12 | return 0 13 | ;; 14 | reboot) 15 | COMPREPLY=( $(compgen -W "bootloader recovery" -- $cur) ) 16 | return 0 17 | ;; 18 | push) 19 | COMPREPLY=( $(compgen -o default -o plusdirs -f -- $cur) ) 20 | return 0 21 | ;; 22 | *) 23 | local prev2="${COMP_WORDS[COMP_CWORD-2]}" 24 | if [ "$prev2" == "push" ] || [ "$prev2" == "reboot" ];then 25 | return 0 26 | fi 27 | ;; 28 | esac 29 | 30 | COMPREPLY=( $(compgen -W "$opts" -- $cur) ) 31 | return 0 32 | } 33 | complete -F _adb adb 34 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/adb.1: -------------------------------------------------------------------------------- 1 | .TH ADB 1 "29 September 2011" 2 | .SH NAME 3 | adb \- android debug bridge 4 | .SH SYNOPSIS 5 | .B adb 6 | [ 7 | .I options 8 | ] 9 | .I command 10 | .LP 11 | .SH DESCRIPTION 12 | .LP 13 | .B adb 14 | 15 | For the full and up to date documentation visit: 16 | 17 | http://developer.android.com/guide/developing/tools/adb.html 18 | 19 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adb.bash-completion: -------------------------------------------------------------------------------- 1 | debian/adb-completion adb 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adb.install: -------------------------------------------------------------------------------- 1 | core/adb/adb usr/bin/ 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adb.manpages: -------------------------------------------------------------------------------- 1 | debian/adb.1 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adb.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # Old udev rules were marking all /dev entries as "uaccess" meaning 6 | # that the current active user could write to any entry. 7 | # A reboot is required to make sure all the permissions are set to 8 | # a sane value again. 9 | if dpkg --compare-versions "$2" lt 4.2.2+git20130218-3ubuntu15 && \ 10 | [ -x /usr/share/update-notifier/notify-reboot-required ] 11 | then 12 | /usr/share/update-notifier/notify-reboot-required || : 13 | fi 14 | 15 | #DEBHELPER# 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adb.udev: -------------------------------------------------------------------------------- 1 | # Udev rules for letting the console user access adb. 2 | # Vendor ids 3 | # Important product ids 4 | # d001 adb recovery 5 | # d002 adb system 6 | 7 | # Applies to 18d1 8 | # 2d00 accessory 9 | # 2d01 accessory,adb 10 | # 2d02 audio_source (part of libgphoto2-2) 11 | # 2d03 audio_source,adb 12 | # 2d04 accessory,audio_source 13 | # 2d05 accessory,audio_source,adb 14 | # 4ee1 mtp (part of libmtp-common) 15 | # 4ee2 mtp,adb (part of libmtp-common) 16 | # 4ee3 rndis 17 | # 4ee4 adb,rdnis 18 | # 4ee5 ptp 19 | # 4ee6 ptp,adb 20 | # 4e41 mtp 21 | # 4e42 mtp,adb 22 | # 4e43 ptp 23 | # 4e44 ptp,adb 24 | # 4e23 rndis 25 | # 4e24 rndis,adb 26 | 27 | ACTION=="add|change", SUBSYSTEM=="usb", \ 28 | ATTRS{idVendor}=="18d1", \ 29 | ATTRS{idProduct}=="2d01|2d03|2d05|4ee2|4ee4|4ee6|4e42|4e44|4e24|d001|d002", \ 30 | TAG+="uaccess" 31 | 32 | # Applies to 04e8 33 | # 685b mass_storage 34 | # 685e mass_storage,adb 35 | # 685c mtp (libgphoto2-2 libmtp-common) 36 | # 6860 mtp,adb (part of libgphoto2-2 libmtp-common) 37 | # 6862 rndis,dm 38 | # 6863 rndis 39 | # 6864 rndis,adb & rndis,acm,dm 40 | # 6865 ptp 41 | # 6866 ptp,adb 42 | # 6864 rndis,dm 43 | # 6865 ptp 44 | # 6866 ptp,adb 45 | 46 | ACTION=="add|change", SUBSYSTEM=="usb", \ 47 | ATTRS{idVendor}=="04e8", \ 48 | ATTRS{idProduct}=="685e|6860|6864|6866|6866", \ 49 | TAG+="uaccess" 50 | 51 | # Applies to 2a45 (Meizu) 52 | 53 | ACTION=="add|change", SUBSYSTEM=="usb", \ 54 | ATTRS{idVendor}=="2a45", \ 55 | ATTRS{idProduct}=="0c01|0c02|2008", \ 56 | TAG+="uaccess" 57 | 58 | # Applies to 2a47 (BQ) 59 | 60 | ACTION=="add|change", SUBSYSTEM=="usb", \ 61 | ATTRS{idVendor}=="2a47", \ 62 | ATTRS{idProduct}=="0c01|0c02|2008", \ 63 | TAG+="uaccess" 64 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adbd.install: -------------------------------------------------------------------------------- 1 | core/adbd/adbd usr/bin/ 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adbd.udev: -------------------------------------------------------------------------------- 1 | ACTION=="add", KERNEL=="android_adb", GROUP="phablet", MODE="0660" 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-adbd.upstart: -------------------------------------------------------------------------------- 1 | # adbd - run adb debugging shell 2 | # 3 | # This task enables the adb shell 4 | 5 | description "adbd" 6 | 7 | start on (android-container persist.sys.usb.config=*adb) and (started lightdm) 8 | stop on runlevel [06] 9 | 10 | normal exit 0 127 11 | 12 | respawn 13 | 14 | pre-start script 15 | if [ -d /sys/class/android_usb ] 16 | then 17 | 18 | if [ -d /sys/class/android_usb/android0/f_ffs ] && \ 19 | [ -n "$(cat /sys/class/android_usb/android0/f_ffs/aliases)" ] 20 | then 21 | if ! $(mount|grep -q ^adb) 22 | then 23 | # some devices use the functionfs (i.e. manta) 24 | # we need to mount it to keep adb working 25 | mkdir -p /dev/usb-ffs/adb 26 | mount -t functionfs adb /dev/usb-ffs/adb || true 27 | fi 28 | fi 29 | else 30 | grep -q qemu /proc/cmdline || { stop; exit 0; } 31 | fi 32 | end script 33 | 34 | exec su - -c adbd 35 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-fastboot.bash-completion: -------------------------------------------------------------------------------- 1 | debian/fastboot-completion fastboot 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-fastboot.install: -------------------------------------------------------------------------------- 1 | core/fastboot/fastboot usr/bin/ 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-fastboot.udev: -------------------------------------------------------------------------------- 1 | # Udev rules for letting the console user access fastboot 2 | # 4e40 grouper 3 | # 4ee0 mako/manta 4 | # 4e30 maguro/toro 5 | 6 | ACTION=="add|change", SUBSYSTEM=="usb", \ 7 | ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4e30|4e40|4ee0", \ 8 | TAG+="uaccess" 9 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/android-tools-fsutils.install: -------------------------------------------------------------------------------- 1 | extras/ext4_utils/ext2simg usr/bin 2 | extras/ext4_utils/ext4fixup usr/bin 3 | extras/ext4_utils/img2simg usr/bin 4 | extras/ext4_utils/make_ext4fs usr/bin 5 | extras/ext4_utils/simg2img usr/bin 6 | extras/ext4_utils/simg2simg usr/bin 7 | extras/ext4_utils/test_ext4fixup usr/bin 8 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/fastboot-completion: -------------------------------------------------------------------------------- 1 | _fastboot() 2 | { 3 | local cur prev opts 4 | COMPREPLY=() 5 | cur="${COMP_WORDS[COMP_CWORD]}" 6 | prev="${COMP_WORDS[COMP_CWORD-1]}" 7 | opts="reboot boot flash devices -w reboot-bootloader" 8 | 9 | case "$prev" in 10 | reboot | devices | -w | reboot-bootloader) 11 | COMPREPLY=() 12 | return 0 13 | ;; 14 | flash) 15 | COMPREPLY=( $(compgen -W "boot system recovery radio" -- $cur )) 16 | return 0 17 | ;; 18 | boot) 19 | COMPREPLY=( $(compgen -o filenames -G "${cur}*.img")) 20 | return 0 21 | ;; 22 | *) 23 | local prev2="${COMP_WORDS[COMP_CWORD-2]}" 24 | local prev3="${COMP_WORDS[COMP_CWORD-3]}" 25 | if [ "$prev2" == "flash" ];then 26 | COMPREPLY=( $(compgen -o filenames -G "${cur}*.img")) 27 | return 0 28 | elif [ "$prev2" == "boot" ];then 29 | COMPREPLY=() 30 | return 0 31 | elif [ "$prev3" == "flash" ];then 32 | COMPREPLY=() 33 | return 0 34 | fi 35 | ;; 36 | esac 37 | 38 | COMPREPLY=( $(compgen -W "$opts" -- $cur) ) 39 | return 0 40 | } 41 | complete -F _fastboot fastboot 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/makefiles/adb.mk: -------------------------------------------------------------------------------- 1 | # Makefile for adb; from https://heiher.info/2227.html 2 | 3 | VPATH+= $(SRCDIR)/core/adb 4 | SRCS+= adb.c 5 | SRCS+= adb_client.c 6 | SRCS+= adb_auth_host.c 7 | SRCS+= commandline.c 8 | SRCS+= console.c 9 | SRCS+= file_sync_client.c 10 | SRCS+= fdevent.c 11 | SRCS+= get_my_path_linux.c 12 | SRCS+= services.c 13 | SRCS+= sockets.c 14 | SRCS+= transport.c 15 | SRCS+= transport_local.c 16 | SRCS+= transport_usb.c 17 | SRCS+= usb_linux.c 18 | SRCS+= usb_vendors.c 19 | SRCS+= utils.c 20 | 21 | VPATH+= $(SRCDIR)/core/libcutils 22 | SRCS+= abort_socket.c 23 | SRCS+= socket_inaddr_any_server.c 24 | SRCS+= socket_local_client.c 25 | SRCS+= socket_local_server.c 26 | SRCS+= socket_loopback_client.c 27 | SRCS+= socket_loopback_server.c 28 | SRCS+= socket_network_client.c 29 | SRCS+= list.c 30 | SRCS+= load_file.c 31 | 32 | VPATH+= $(SRCDIR)/core/libzipfile 33 | SRCS+= centraldir.c 34 | SRCS+= zipfile.c 35 | 36 | 37 | CPPFLAGS+= -DADB_HOST=1 38 | CPPFLAGS+= -DHAVE_FORKEXEC=1 39 | CPPFLAGS+= -DHAVE_SYMLINKS 40 | CPPFLAGS+= -DHAVE_TERMIO_H 41 | CPPFLAGS+= -I$(SRCDIR)/core/adb 42 | CPPFLAGS+= -I$(SRCDIR)/core/include 43 | 44 | LIBS+= -lc -lpthread -lz `pkg-config --libs libcrypto` 45 | 46 | OBJS= $(SRCS:.c=.o) 47 | 48 | all: adb 49 | 50 | adb: $(OBJS) 51 | $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 52 | 53 | clean: 54 | rm -rf $(OBJS) adb 55 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/makefiles/adbd.mk: -------------------------------------------------------------------------------- 1 | # Makefile for adbd 2 | 3 | VPATH+= $(SRCDIR)/core/adbd 4 | SRCS+= adb.c 5 | SRCS+= backup_service.c 6 | SRCS+= fdevent.c 7 | SRCS+= transport.c 8 | SRCS+= transport_local.c 9 | SRCS+= transport_usb.c 10 | SRCS+= adb_auth_client.c 11 | SRCS+= sockets.c 12 | SRCS+= services.c 13 | SRCS+= file_sync_service.c 14 | SRCS+= jdwp_service.c 15 | SRCS+= framebuffer_service.c 16 | SRCS+= remount_service.c 17 | SRCS+= usb_linux_client.c 18 | SRCS+= log_service.c 19 | SRCS+= utils.c 20 | SRCS+= base64.c 21 | 22 | VPATH+= $(SRCDIR)/core/libcutils 23 | SRCS+= abort_socket.c 24 | SRCS+= socket_inaddr_any_server.c 25 | SRCS+= socket_local_client.c 26 | SRCS+= socket_local_server.c 27 | SRCS+= socket_loopback_client.c 28 | SRCS+= socket_loopback_server.c 29 | SRCS+= socket_network_client.c 30 | SRCS+= list.c 31 | SRCS+= load_file.c 32 | SRCS+= android_reboot.c 33 | 34 | VPATH+= $(SRCDIR)/core/libzipfile 35 | SRCS+= centraldir.c 36 | SRCS+= zipfile.c 37 | 38 | 39 | CPPFLAGS+= -O2 -g -Wall -Wno-unused-parameter 40 | CPPFLAGS+= -DADB_HOST=0 -DHAVE_FORKEXEC=1 -D_XOPEN_SOURCE -D_GNU_SOURCE -DALLOW_ADBD_ROOT=1 41 | CPPFLAGS+= -DHAVE_SYMLINKS -DBOARD_ALWAYS_INSECURE 42 | CPPFLAGS+= -DHAVE_TERMIO_H 43 | CPPFLAGS+= -DADBD_NON_ANDROID 44 | CPPFLAGS+= -I$(SRCDIR)/core/adbd 45 | CPPFLAGS+= -I$(SRCDIR)/core/include 46 | 47 | LIBS+= -lc -lpthread -lz `pkg-config --libs libcrypto` -lcrypt 48 | 49 | OBJS= $(patsubst %, %.o, $(basename $(SRCS))) 50 | 51 | all: adbd 52 | 53 | adbd: $(OBJS) 54 | $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 55 | 56 | #%.o: 57 | # echo $(OBJS) 58 | # $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) -c $(wildcard $(addprefix $(CURDIR)/../*/,$(patsubst %.o, %.c, $@))) 59 | clean: 60 | rm -rf $(OBJS) adbd 61 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/makefiles/ext4_utils.mk: -------------------------------------------------------------------------------- 1 | # Makefile for ext4_utils; based on https://heiher.info/2227.html 2 | # Author: Dmitrijs Ledkovs 3 | 4 | VPATH+=$(SRCDIR)/extras/ext4_utils 5 | SRCS+=make_ext4fs.c 6 | SRCS+=ext4fixup.c 7 | SRCS+=ext4_utils.c 8 | SRCS+=allocate.c 9 | SRCS+=contents.c 10 | SRCS+=extent.c 11 | SRCS+=indirect.c 12 | SRCS+=uuid.c 13 | SRCS+=sha1.c 14 | SRCS+=wipe.c 15 | SRCS+=crc16.c 16 | 17 | VPATH+=$(SRCDIR)/core/libsparse 18 | SRCS+= backed_block.c 19 | SRCS+= sparse_crc32.c 20 | SRCS+= sparse.c 21 | SRCS+= sparse_read.c 22 | SRCS+= sparse_err.c 23 | SRCS+= output_file.c 24 | 25 | OBJS_SHARED:= $(SRCS:.c=.o) 26 | 27 | SRCS+=make_ext4fs_main.c 28 | SRCS+=ext4fixup_main.c 29 | SRCS+=setup_fs.c 30 | SRCS+=ext2simg.c 31 | SRCS+=img2simg.c 32 | SRCS+=simg2img.c 33 | SRCS+=simg2simg.c 34 | 35 | CPPFLAGS+= -I$(SRCDIR) 36 | CPPFLAGS+= -I$(SRCDIR)/core/include 37 | CPPFLAGS+= -I$(SRCDIR)/core/libsparse/include/ 38 | 39 | LIBS+= -lz -lselinux 40 | 41 | OBJS= $(SRCS:.c=.o) 42 | 43 | all: make_ext4fs ext4fixup ext2simg img2simg simg2img simg2simg 44 | 45 | make_ext4fs ext4fixup: $(OBJS) 46 | $(CC) -o $@ $(LDFLAGS) $(OBJS_SHARED) $@_main.o $(LIBS) 47 | 48 | ext2simg img2simg simg2img simg2simg: $(OBJS) 49 | $(CC) -o $@ $(LDFLAGS) $(OBJS_SHARED) $@.o $(LIBS) 50 | 51 | clean: 52 | rm -rf $(OBJS) ext2simg ext4fixup make_ext4fs img2simg simg2img simg2simg 53 | 54 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/makefiles/fastboot.mk: -------------------------------------------------------------------------------- 1 | # Makefile for fastboot; from https://heiher.info/2227.html 2 | 3 | VPATH+= $(SRCDIR)/core/fastboot 4 | SRCS+= bootimg.c 5 | SRCS+= engine.c 6 | SRCS+= fastboot.c 7 | SRCS+= protocol.c 8 | SRCS+= usb_linux.c 9 | SRCS+= util_linux.c 10 | 11 | VPATH+= $(SRCDIR)/core/libzipfile 12 | SRCS+= centraldir.c 13 | SRCS+= zipfile.c 14 | 15 | VPATH+= $(SRCDIR)/core/libsparse 16 | SRCS+= backed_block.c 17 | SRCS+= sparse_crc32.c 18 | SRCS+= sparse.c 19 | SRCS+= sparse_read.c 20 | SRCS+= sparse_err.c 21 | SRCS+= output_file.c 22 | 23 | VPATH+= $(SRCDIR)/extras/ext4_utils/ 24 | SRCS+= make_ext4fs.c 25 | SRCS+= crc16.c 26 | SRCS+= ext4_utils.c 27 | SRCS+= indirect.c 28 | SRCS+= allocate.c 29 | SRCS+= contents.c 30 | SRCS+= uuid.c 31 | SRCS+= extent.c 32 | SRCS+= wipe.c 33 | SRCS+= sha1.c 34 | 35 | CPPFLAGS+= -I$(SRCDIR)/core/fastboot 36 | CPPFLAGS+= -I$(SRCDIR)/core/include 37 | CPPFLAGS+= -I$(SRCDIR)/core/mkbootimg 38 | CPPFLAGS+= -I$(SRCDIR)/extras/ext4_utils/ 39 | CPPFLAGS+= -I$(SRCDIR)/core/libsparse/include/ 40 | 41 | LIBS+= -lz -lselinux 42 | 43 | OBJS= $(SRCS:.c=.o) 44 | 45 | all: fastboot 46 | 47 | fastboot: $(OBJS) 48 | $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 49 | 50 | clean: 51 | rm -rf $(OBJS) fastboot 52 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/add-bq-vendor-id.patch: -------------------------------------------------------------------------------- 1 | ## Description: Let adb detect devices from BQ. 2 | ## Origin/Author: Jani Monoses 3 | Index: android-tools-4.2.2+git20130218/core/adb/usb_vendors.c 4 | =================================================================== 5 | --- android-tools-4.2.2+git20130218.orig/core/adb/usb_vendors.c 6 | +++ android-tools-4.2.2+git20130218/core/adb/usb_vendors.c 7 | @@ -131,6 +131,8 @@ 8 | #define VENDOR_ID_KOBO 0x2237 9 | // Teleepoch's USB Vendor ID 10 | #define VENDOR_ID_TELEEPOCH 0x2340 11 | +// BQ's USB Vendor ID 12 | +#define VENDOR_ID_BQ 0x2a47 13 | 14 | 15 | /** built-in vendor list */ 16 | @@ -183,6 +185,7 @@ int builtInVendorIds[] = { 17 | VENDOR_ID_YULONG_COOLPAD, 18 | VENDOR_ID_KOBO, 19 | VENDOR_ID_TELEEPOCH, 20 | + VENDOR_ID_BQ, 21 | }; 22 | 23 | #define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0])) 24 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/add-meizu-vendor-id.patch: -------------------------------------------------------------------------------- 1 | ## Description: add some description 2 | ## Origin/Author: add some origin or author 3 | ## Bug: bug URL 4 | Index: android-tools-4.2.2+git20130218/core/adb/usb_vendors.c 5 | =================================================================== 6 | --- android-tools-4.2.2+git20130218.orig/core/adb/usb_vendors.c 7 | +++ android-tools-4.2.2+git20130218/core/adb/usb_vendors.c 8 | @@ -131,6 +131,8 @@ 9 | #define VENDOR_ID_KOBO 0x2237 10 | // Teleepoch's USB Vendor ID 11 | #define VENDOR_ID_TELEEPOCH 0x2340 12 | +// Meizu's USB Vendor ID 13 | +#define VENDOR_ID_MEIZU 0x2a45 14 | // BQ's USB Vendor ID 15 | #define VENDOR_ID_BQ 0x2a47 16 | 17 | @@ -185,6 +187,7 @@ int builtInVendorIds[] = { 18 | VENDOR_ID_YULONG_COOLPAD, 19 | VENDOR_ID_KOBO, 20 | VENDOR_ID_TELEEPOCH, 21 | + VENDOR_ID_MEIZU, 22 | VENDOR_ID_BQ, 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/enable-emulator.patch: -------------------------------------------------------------------------------- 1 | Description: enable emulator check 2 | Author: Dmitrijs Ledkovs 3 | 4 | --- android-tools-4.2.2+git20130218.orig/core/adbd/transport_local.c 5 | +++ android-tools-4.2.2+git20130218/core/adbd/transport_local.c 6 | @@ -309,15 +309,16 @@ void local_init(int port) 7 | #else 8 | /* For the adbd daemon in the system image we need to distinguish 9 | * between the device, and the emulator. */ 10 | - char is_qemu[PROPERTY_VALUE_MAX]; 11 | + //char is_qemu[PROPERTY_VALUE_MAX]; 12 | //property_get("ro.kernel.qemu", is_qemu, ""); 13 | //if (!strcmp(is_qemu, "1")) { 14 | + if (access("/dev/qemu_pipe", R_OK|W_OK) != -1) { 15 | /* Running inside the emulator: use QEMUD pipe as the transport. */ 16 | - // func = qemu_socket_thread; 17 | - //} else { 18 | + func = qemu_socket_thread; 19 | + } else { 20 | /* Running inside the device: use TCP socket as the transport. */ 21 | func = server_socket_thread; 22 | - //} 23 | + } 24 | #endif // !ADB_HOST 25 | } 26 | 27 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/ppc64el-ftbfs.patch: -------------------------------------------------------------------------------- 1 | Author: Steve Langasek 2 | Description: Fix build failure on ppc64el 3 | On ppc64/ppc64el, the Linux kernel headers default to defining __u64 as 4 | 'unsigned long int' for "compatibility". However, this is incompatible 5 | with android-tools' own definition of the type. Use the 6 | __SANE_USERSPACE_TYPES__ define to get kernel header behavior consistent 7 | with other architectures. 8 | Index: android-tools-4.2.2+git20130218/extras/ext4_utils/ext4_utils.c 9 | =================================================================== 10 | --- android-tools-4.2.2+git20130218.orig/extras/ext4_utils/ext4_utils.c 2014-02-22 00:36:30.665154000 +0000 11 | +++ android-tools-4.2.2+git20130218/extras/ext4_utils/ext4_utils.c 2014-02-22 00:36:30.655154000 +0000 12 | @@ -36,6 +36,7 @@ 13 | #endif 14 | 15 | #if defined(__linux__) 16 | +#define __SANE_USERSPACE_TYPES__ 17 | #include 18 | #elif defined(__APPLE__) && defined(__MACH__) 19 | #include 20 | Index: android-tools-4.2.2+git20130218/extras/ext4_utils/make_ext4fs_main.c 21 | =================================================================== 22 | --- android-tools-4.2.2+git20130218.orig/extras/ext4_utils/make_ext4fs_main.c 2014-02-14 18:26:17.000000000 +0000 23 | +++ android-tools-4.2.2+git20130218/extras/ext4_utils/make_ext4fs_main.c 2014-02-22 00:37:41.735153984 +0000 24 | @@ -20,6 +20,7 @@ 25 | #include 26 | 27 | #if defined(__linux__) 28 | +#define __SANE_USERSPACE_TYPES__ 29 | #include 30 | #elif defined(__APPLE__) && defined(__MACH__) 31 | #include 32 | Index: android-tools-4.2.2+git20130218/extras/ext4_utils/wipe.c 33 | =================================================================== 34 | --- android-tools-4.2.2+git20130218.orig/extras/ext4_utils/wipe.c 2013-02-18 14:49:03.000000000 +0000 35 | +++ android-tools-4.2.2+git20130218/extras/ext4_utils/wipe.c 2014-02-22 00:37:37.225155283 +0000 36 | @@ -19,6 +19,7 @@ 37 | 38 | #if defined(__linux__) 39 | 40 | +#define __SANE_USERSPACE_TYPES__ 41 | #include 42 | #include 43 | 44 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/reboot-syscall.patch: -------------------------------------------------------------------------------- 1 | Subject: port android_reboot() to call the reboot syscall via syscall() (glibc) rather than __reboot (bionic) 2 | Author: Loïc Minier 3 | 4 | --- a/core/libcutils/android_reboot.c 5 | +++ b/core/libcutils/android_reboot.c 6 | @@ -21,6 +21,8 @@ 7 | #include 8 | #include 9 | #include 10 | +#include 11 | +#include 12 | 13 | #include 14 | 15 | @@ -121,8 +123,8 @@ 16 | break; 17 | 18 | case ANDROID_RB_RESTART2: 19 | - ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, 20 | - LINUX_REBOOT_CMD_RESTART2, arg); 21 | + ret = syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, 22 | + LINUX_REBOOT_CMD_RESTART2, arg); 23 | break; 24 | 25 | default: 26 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/remove-selinux-android.patch: -------------------------------------------------------------------------------- 1 | Subject: drop useless includes of Android SELINUX extensions; avoids having to clone another module; this should be sent upstream 2 | Author: Sergio Schvezov 3 | 4 | --- a/extras/ext4_utils/make_ext4fs.c 5 | +++ b/extras/ext4_utils/make_ext4fs.c 6 | @@ -61,7 +61,6 @@ 7 | 8 | #include 9 | #include 10 | -#include 11 | 12 | #define O_BINARY 0 13 | 14 | --- a/extras/ext4_utils/make_ext4fs_main.c 15 | +++ b/extras/ext4_utils/make_ext4fs_main.c 16 | @@ -32,7 +32,6 @@ 17 | #ifndef USE_MINGW 18 | #include 19 | #include 20 | -#include 21 | #else 22 | struct selabel_handle; 23 | #endif 24 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/patches/series: -------------------------------------------------------------------------------- 1 | remove-selinux-android.patch 2 | add_adbd.patch 3 | reboot-syscall.patch 4 | enable-emulator.patch 5 | ppc64el-ftbfs.patch 6 | add-bq-vendor-id.patch 7 | add-meizu-vendor-id.patch 8 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 4 | 5 | export CC := $(DEB_HOST_GNU_TYPE)-gcc 6 | 7 | M := $(CURDIR)/debian/makefiles 8 | 9 | INSTALL := install 10 | INSTALL_PROGRAM = $(INSTALL) 11 | 12 | %: 13 | dh $@ --with python2 --with bash-completion 14 | 15 | override_dh_clean: 16 | dh_clean 17 | $(MAKE) -f $(M)/adb.mk -C core/adb clean 18 | ifeq (,$(filter $(DEB_HOST_ARCH),powerpc)) 19 | $(MAKE) -f $(M)/adbd.mk -C core/adbd clean 20 | endif 21 | $(MAKE) -f $(M)/fastboot.mk -C core/fastboot clean 22 | $(MAKE) -f $(M)/ext4_utils.mk -C extras/ext4_utils clean 23 | 24 | override_dh_auto_build: 25 | $(MAKE) -f $(M)/adb.mk -C core/adb 26 | ifeq (,$(filter $(DEB_HOST_ARCH),powerpc)) 27 | $(MAKE) -f $(M)/adbd.mk -C core/adbd 28 | endif 29 | $(MAKE) -f $(M)/fastboot.mk -C core/fastboot 30 | $(MAKE) -f $(M)/ext4_utils.mk -C extras/ext4_utils 31 | 32 | override_dh_install: 33 | dh_install --sourcedir=. 34 | $(INSTALL_PROGRAM) core/libsparse/simg_dump.py debian/android-tools-fsutils/usr/bin/simg_dump 35 | $(INSTALL_PROGRAM) extras/ext4_utils/mkuserimg.sh debian/android-tools-fsutils/usr/bin/mkuserimg 36 | 37 | override_dh_installudev: 38 | dh_installudev -p android-tools-adb --priority=70 39 | dh_installudev -p android-tools-fastboot --priority=70 40 | dh_installudev -p android-tools-adbd --priority=98 41 | 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/allocate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ALLOCATE_H_ 18 | #define _ALLOCATE_H_ 19 | 20 | #define EXT4_ALLOCATE_FAILED (u32)(~0) 21 | 22 | #include "ext4_utils.h" 23 | #include "ext4.h" 24 | 25 | struct block_allocation; 26 | 27 | void block_allocator_init(); 28 | void block_allocator_free(); 29 | u32 allocate_block(); 30 | struct block_allocation *allocate_blocks(u32 len); 31 | int block_allocation_num_regions(struct block_allocation *alloc); 32 | int block_allocation_len(struct block_allocation *alloc); 33 | struct ext4_inode *get_inode(u32 inode); 34 | void reduce_allocation(struct block_allocation *alloc, u32 len); 35 | u32 get_block(struct block_allocation *alloc, u32 block); 36 | u32 get_oob_block(struct block_allocation *alloc, u32 block); 37 | void get_next_region(struct block_allocation *alloc); 38 | void get_region(struct block_allocation *alloc, u32 *block, u32 *len); 39 | u32 get_free_blocks(u32 bg); 40 | u32 get_free_inodes(u32 bg); 41 | u32 reserve_inodes(int bg, u32 inodes); 42 | void add_directory(u32 inode); 43 | u16 get_directories(int bg); 44 | u16 get_bg_flags(int bg); 45 | void init_unused_inode_tables(void); 46 | u32 allocate_inode(); 47 | void free_alloc(struct block_allocation *alloc); 48 | int reserve_oob_blocks(struct block_allocation *alloc, int blocks); 49 | int advance_blocks(struct block_allocation *alloc, int blocks); 50 | int advance_oob_blocks(struct block_allocation *alloc, int blocks); 51 | int last_region(struct block_allocation *alloc); 52 | void rewind_alloc(struct block_allocation *alloc); 53 | void append_region(struct block_allocation *alloc, 54 | u32 block, u32 len, int bg); 55 | struct block_allocation *create_allocation(); 56 | int append_oob_allocation(struct block_allocation *alloc, u32 len); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/contents.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _DIRECTORY_H_ 18 | #define _DIRECTORY_H_ 19 | 20 | struct dentry { 21 | char *path; 22 | char *full_path; 23 | const char *filename; 24 | char *link; 25 | unsigned long size; 26 | u8 file_type; 27 | u16 mode; 28 | u16 uid; 29 | u16 gid; 30 | u32 *inode; 31 | u32 mtime; 32 | char *secon; 33 | }; 34 | 35 | u32 make_directory(u32 dir_inode_num, u32 entries, struct dentry *dentries, 36 | u32 dirs); 37 | u32 make_file(const char *filename, u64 len); 38 | u32 make_link(const char *filename, const char *link); 39 | int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime); 40 | int inode_set_selinux(u32 inode_num, const char *secon); 41 | #endif 42 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/ext4fixup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | int ext4fixup(char *fsdev); 18 | int ext4fixup_internal(char *fsdev, int v_flag, int n_flag, 19 | int stop_phase, int stop_loc, int stop_count); 20 | 21 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/ext4fixup_main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "ext4fixup.h" 22 | 23 | static void usage(char *me) 24 | { 25 | fprintf(stderr, "%s: usage: %s [-vn] \n", me, me); 26 | } 27 | 28 | int main(int argc, char **argv) 29 | { 30 | int opt; 31 | int verbose = 0; 32 | int no_write = 0; 33 | char *fsdev; 34 | char *me; 35 | int stop_phase = 0, stop_loc = 0, stop_count = 0; 36 | 37 | me = basename(argv[0]); 38 | 39 | while ((opt = getopt(argc, argv, "vnd:")) != -1) { 40 | switch (opt) { 41 | case 'v': 42 | verbose = 1; 43 | break; 44 | case 'n': 45 | no_write = 1; 46 | break; 47 | case 'd': 48 | sscanf(optarg, "%d,%d,%d", &stop_phase, &stop_loc, &stop_count); 49 | break; 50 | } 51 | } 52 | 53 | if (optind >= argc) { 54 | fprintf(stderr, "expected image or block device after options\n"); 55 | usage(me); 56 | exit(EXIT_FAILURE); 57 | } 58 | 59 | fsdev = argv[optind++]; 60 | 61 | if (optind < argc) { 62 | fprintf(stderr, "Unexpected argument: %s\n", argv[optind]); 63 | usage(me); 64 | exit(EXIT_FAILURE); 65 | } 66 | 67 | return ext4fixup_internal(fsdev, verbose, no_write, stop_phase, stop_loc, stop_count); 68 | } 69 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/extent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EXTENT_H_ 18 | #define _EXTENT_H_ 19 | 20 | #include "allocate.h" 21 | #include "ext4_utils.h" 22 | 23 | void inode_allocate_extents(struct ext4_inode *inode, u64 len); 24 | void inode_allocate_file_extents(struct ext4_inode *inode, u64 len, 25 | const char *filename); 26 | u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len, 27 | u64 backing_len); 28 | void free_extent_blocks(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/indirect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INDIRECT_H_ 18 | #define _INDIRECT_H_ 19 | 20 | #include "allocate.h" 21 | 22 | void inode_allocate_indirect(struct ext4_inode *inode, unsigned long len); 23 | u8 *inode_allocate_data_indirect(struct ext4_inode *inode, unsigned long len, 24 | unsigned long backing_len); 25 | void inode_attach_resize(struct ext4_inode *inode, 26 | struct block_allocation *alloc); 27 | void free_indirect_blocks(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/make_ext4fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MAKE_EXT4FS_H_ 18 | #define _MAKE_EXT4FS_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct selabel_handle; 25 | 26 | int make_ext4fs(const char *filename, long long len, 27 | const char *mountpoint, struct selabel_handle *sehnd); 28 | int make_ext4fs_sparse_fd(int fd, long long len, 29 | const char *mountpoint, struct selabel_handle *sehnd); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/mkuserimg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | # 3 | # To call this script, make sure make_ext4fs is somewhere in PATH 4 | 5 | function usage() { 6 | cat< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | const char *mkfs = "/system/bin/make_ext4fs"; 11 | 12 | int setup_fs(const char *blockdev) 13 | { 14 | char buf[256], path[128]; 15 | pid_t child; 16 | int status, n; 17 | pid_t pid; 18 | 19 | /* we might be looking at an indirect reference */ 20 | n = readlink(blockdev, path, sizeof(path) - 1); 21 | if (n > 0) { 22 | path[n] = 0; 23 | if (!memcmp(path, "/dev/block/", 11)) 24 | blockdev = path + 11; 25 | } 26 | 27 | if (strchr(blockdev,'/')) { 28 | fprintf(stderr,"not a block device name: %s\n", blockdev); 29 | return 0; 30 | } 31 | 32 | snprintf(buf, sizeof(buf), "/sys/fs/ext4/%s", blockdev); 33 | if (access(buf, F_OK) == 0) { 34 | fprintf(stderr,"device %s already has a filesystem\n", blockdev); 35 | return 0; 36 | } 37 | snprintf(buf, sizeof(buf), "/dev/block/%s", blockdev); 38 | 39 | if (!partition_wiped(buf)) { 40 | fprintf(stderr,"device %s not wiped, probably encrypted, not wiping\n", blockdev); 41 | return 0; 42 | } 43 | 44 | fprintf(stderr,"+++\n"); 45 | 46 | child = fork(); 47 | if (child < 0) { 48 | fprintf(stderr,"error: setup_fs: fork failed\n"); 49 | return 0; 50 | } 51 | if (child == 0) { 52 | execl(mkfs, mkfs, buf, NULL); 53 | exit(-1); 54 | } 55 | 56 | while ((pid=waitpid(-1, &status, 0)) != child) { 57 | if (pid == -1) { 58 | fprintf(stderr, "error: setup_fs: waitpid failed!\n"); 59 | return 1; 60 | } 61 | } 62 | 63 | fprintf(stderr,"---\n"); 64 | return 1; 65 | } 66 | 67 | 68 | int main(int argc, char **argv) 69 | { 70 | int need_reboot = 0; 71 | 72 | while (argc > 1) { 73 | if (strlen(argv[1]) < 128) 74 | need_reboot |= setup_fs(argv[1]); 75 | argv++; 76 | argc--; 77 | } 78 | 79 | if (need_reboot) { 80 | fprintf(stderr,"REBOOT!\n"); 81 | android_reboot(ANDROID_RB_RESTART, 0, 0); 82 | exit(-1); 83 | } 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/sha1.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | */ 8 | 9 | #ifndef _SYS_SHA1_H_ 10 | #define _SYS_SHA1_H_ 11 | 12 | #include 13 | #include 14 | 15 | #ifdef USE_MINGW 16 | typedef unsigned char u_char; 17 | typedef unsigned int uint32_t; 18 | typedef unsigned int u_int32_t; 19 | typedef unsigned int u_int; 20 | 21 | #define __BEGIN_DECLS 22 | #define __END_DECLS 23 | #else 24 | #include 25 | #endif 26 | 27 | #define SHA1_DIGEST_LENGTH 20 28 | #define SHA1_DIGEST_STRING_LENGTH 41 29 | 30 | typedef struct { 31 | uint32_t state[5]; 32 | uint32_t count[2]; 33 | u_char buffer[64]; 34 | } SHA1_CTX; 35 | 36 | __BEGIN_DECLS 37 | void SHA1Transform(uint32_t[5], const u_char[64]); 38 | void SHA1Init(SHA1_CTX *); 39 | void SHA1Update(SHA1_CTX *, const u_char *, u_int); 40 | void SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *); 41 | __END_DECLS 42 | 43 | #endif /* _SYS_SHA1_H_ */ 44 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/test_ext4fixup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | typeset -i I ITERATIONS PHASE LOC COUNT MAXCOUNT 4 | 5 | ME=`basename $0` 6 | 7 | if [ "$#" -ne 3 ] 8 | then 9 | echo "$ME: Usage: $ME " >&2 10 | exit 1; 11 | fi 12 | 13 | ITERATIONS="$1" 14 | MAXCOUNT="$2" 15 | ORIG_FS_IMAGE="$3" 16 | FIXED_FS_IMAGE="/tmp/fixedfsimage.$$" 17 | NEW_FS_IMAGE="/tmp/newfsimage.$$" 18 | 19 | if [ ! -f "$ORIG_FS_IMAGE" ] 20 | then 21 | echo "$ME: Filesystem image $NEW_FS_IMAGE does not exist" >&2 22 | exit 1 23 | fi 24 | 25 | trap "rm -f $NEW_FS_IMAGE $FIXED_FS_IMAGE" 0 1 2 3 15 26 | 27 | rm -f "$NEW_FS_IMAGE" "$FIXED_FS_IMAGE" 28 | 29 | # Create the fixed image to compare against 30 | cp "$ORIG_FS_IMAGE" "$FIXED_FS_IMAGE" 31 | ext4fixup "$FIXED_FS_IMAGE" 32 | 33 | if [ "$?" -ne 0 ] 34 | then 35 | echo "$ME: ext4fixup failed!\n" 36 | exit 1 37 | fi 38 | 39 | I=0 40 | while [ "$I" -lt "$ITERATIONS" ] 41 | do 42 | # There is also a phase 4, which is writing out the updated superblocks and 43 | # block group descriptors. Test the with a separate script. 44 | let PHASE="$RANDOM"%3 # 0 to 2 45 | let PHASE++ # 1 to 3 46 | let LOC="$RANDOM"%2 # 0 to 1 47 | let LOC++ # 1 to 2 48 | let COUNT="$RANDOM"%"$MAXCOUNT" 49 | 50 | # Make a copy of the original image to fixup 51 | cp "$ORIG_FS_IMAGE" "$NEW_FS_IMAGE" 52 | 53 | # Run the fixup tool, but die partway through to see if we can recover 54 | ext4fixup -d "$PHASE,$LOC,$COUNT" "$NEW_FS_IMAGE" 2>/dev/null 55 | 56 | # run it again without -d to have it finish the job 57 | ext4fixup "$NEW_FS_IMAGE" 58 | 59 | if cmp "$FIXED_FS_IMAGE" "$NEW_FS_IMAGE" 60 | then 61 | : 62 | else 63 | echo "$ME: test failed with parameters $PHASE, $LOC, $COUNT" 64 | exit 1 65 | fi 66 | 67 | rm -f "$NEW_FS_IMAGE" 68 | 69 | let I++ 70 | done 71 | 72 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/uuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #ifdef USE_MINGW 20 | #include 21 | #else 22 | #include 23 | #endif 24 | 25 | #include "ext4_utils.h" 26 | #include "sha1.h" 27 | #include "uuid.h" 28 | 29 | /* Definition from RFC-4122 */ 30 | struct uuid { 31 | u32 time_low; 32 | u16 time_mid; 33 | u16 time_hi_and_version; 34 | u8 clk_seq_hi_res; 35 | u8 clk_seq_low; 36 | u16 node0_1; 37 | u32 node2_5; 38 | }; 39 | 40 | static void sha1_hash(const char *namespace, const char *name, 41 | unsigned char sha1[SHA1_DIGEST_LENGTH]) 42 | { 43 | SHA1_CTX ctx; 44 | SHA1Init(&ctx); 45 | SHA1Update(&ctx, (const u8*)namespace, strlen(namespace)); 46 | SHA1Update(&ctx, (const u8*)name, strlen(name)); 47 | SHA1Final(sha1, &ctx); 48 | } 49 | 50 | void generate_uuid(const char *namespace, const char *name, u8 result[16]) 51 | { 52 | unsigned char sha1[SHA1_DIGEST_LENGTH]; 53 | struct uuid *uuid = (struct uuid *)result; 54 | 55 | sha1_hash(namespace, name, (unsigned char*)sha1); 56 | memcpy(uuid, sha1, sizeof(struct uuid)); 57 | 58 | uuid->time_low = ntohl(uuid->time_low); 59 | uuid->time_mid = ntohs(uuid->time_mid); 60 | uuid->time_hi_and_version = ntohs(uuid->time_hi_and_version); 61 | uuid->time_hi_and_version &= 0x0FFF; 62 | uuid->time_hi_and_version |= (5 << 12); 63 | uuid->clk_seq_hi_res &= ~(1 << 6); 64 | uuid->clk_seq_hi_res |= 1 << 7; 65 | } 66 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _UUID_H_ 18 | #define _UUID_H_ 19 | 20 | #include "ext4_utils.h" 21 | 22 | void generate_uuid(const char *namespace, const char *name, u8 result[16]); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/wipe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "ext4_utils.h" 18 | #include "wipe.h" 19 | 20 | #if defined(__linux__) 21 | 22 | #define __SANE_USERSPACE_TYPES__ 23 | #include 24 | #include 25 | 26 | #ifndef BLKDISCARD 27 | #define BLKDISCARD _IO(0x12,119) 28 | #endif 29 | 30 | #ifndef BLKSECDISCARD 31 | #define BLKSECDISCARD _IO(0x12,125) 32 | #endif 33 | 34 | int wipe_block_device(int fd, s64 len) 35 | { 36 | u64 range[2]; 37 | int ret; 38 | 39 | range[0] = 0; 40 | range[1] = len; 41 | ret = ioctl(fd, BLKSECDISCARD, &range); 42 | if (ret < 0) { 43 | range[0] = 0; 44 | range[1] = len; 45 | ret = ioctl(fd, BLKDISCARD, &range); 46 | if (ret < 0) { 47 | warn("Discard failed\n"); 48 | return 1; 49 | } else { 50 | warn("Wipe via secure discard failed, used discard instead\n"); 51 | return 0; 52 | } 53 | } 54 | 55 | return 0; 56 | } 57 | #else 58 | int wipe_block_device(int fd, s64 len) 59 | { 60 | error("wipe not supported on non-linux platforms"); 61 | return 1; 62 | } 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/wipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _WIPE_H_ 18 | #define _WIPE_H_ 19 | 20 | int wipe_block_device(int fd, s64 len); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /android-tools-4.2.2/extras/ext4_utils/xattr.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define EXT4_XATTR_MAGIC 0xEA020000 4 | #define EXT4_XATTR_INDEX_SECURITY 6 5 | 6 | struct ext4_xattr_entry { 7 | __u8 e_name_len; 8 | __u8 e_name_index; 9 | __le16 e_value_offs; 10 | __le32 e_value_block; 11 | __le32 e_value_size; 12 | __le32 e_hash; 13 | char e_name[0]; 14 | }; 15 | 16 | #define EXT4_XATTR_PAD_BITS 2 17 | #define EXT4_XATTR_PAD (1<