src/sockets.c \
src/services.c \
src/file_sync_service.c \
- src/framebuffer_service.c \
- src/remount_service.c \
src/usb_linux_client.c \
src/utils.c \
src/socket_inaddr_any_server.c \
src/socket_loopback_server.c \
src/socket_network_client.c \
src/properties.c \
- src/android_reboot.c \
src/sdktools.c \
src/strutils.c \
src/libsmack.c \
Name: sdbd
Summary: SDB daemon
Version: 2.2.0
-Release: 1
+Release: 2
Group: TO_BE/FILLED_IN
License: TO BE FILLED IN
Source0: %{name}-%{version}.tar.gz
+++ /dev/null
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for adb
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-# adb host tool
-# =========================================================
-include $(CLEAR_VARS)
-
-# Default to a virtual (sockets) usb interface
-USB_SRCS :=
-EXTRA_SRCS :=
-
-ifeq ($(HOST_OS),linux)
- USB_SRCS := usb_linux.c
- EXTRA_SRCS := get_my_path_linux.c
- LOCAL_LDLIBS += -lrt -lncurses -lpthread
-endif
-
-ifeq ($(HOST_OS),darwin)
- USB_SRCS := usb_osx.c
- EXTRA_SRCS := get_my_path_darwin.c
- LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
-endif
-
-ifeq ($(HOST_OS),freebsd)
- USB_SRCS := usb_libusb.c
- EXTRA_SRCS := get_my_path_freebsd.c
- LOCAL_LDLIBS += -lpthread -lusb
-endif
-
-ifeq ($(HOST_OS),windows)
- USB_SRCS := usb_windows.c
- EXTRA_SRCS := get_my_path_windows.c
- EXTRA_STATIC_LIBS := AdbWinApi
- ifneq ($(strip $(USE_CYGWIN)),)
- # Pure cygwin case
- LOCAL_LDLIBS += -lpthread
- LOCAL_C_INCLUDES += /usr/include/w32api/ddk
- endif
- ifneq ($(strip $(USE_MINGW)),)
- # MinGW under Linux case
- LOCAL_LDLIBS += -lws2_32
- USE_SYSDEPS_WIN32 := 1
- LOCAL_C_INCLUDES += /usr/i586-mingw32msvc/include/ddk
- endif
- LOCAL_C_INCLUDES += development/host/windows/usb/api/
-endif
-
-LOCAL_SRC_FILES := \
- adb.c \
- console.c \
- transport.c \
- transport_local.c \
- transport_usb.c \
- commandline.c \
- adb_client.c \
- sockets.c \
- services.c \
- file_sync_client.c \
- $(EXTRA_SRCS) \
- $(USB_SRCS) \
- utils.c \
- usb_vendors.c
-
-
-ifneq ($(USE_SYSDEPS_WIN32),)
- LOCAL_SRC_FILES += sysdeps_win32.c
-else
- LOCAL_SRC_FILES += fdevent.c
-endif
-
-LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter
-LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
-LOCAL_MODULE := adb
-
-LOCAL_STATIC_LIBRARIES := libzipfile libunz $(EXTRA_STATIC_LIBS)
-ifeq ($(USE_SYSDEPS_WIN32),)
- LOCAL_STATIC_LIBRARIES += libcutils
-endif
-
-include $(BUILD_HOST_EXECUTABLE)
-
-$(call dist-for-goals,droid,$(LOCAL_BUILT_MODULE))
-
-ifeq ($(HOST_OS),windows)
-$(LOCAL_INSTALLED_MODULE): \
- $(HOST_OUT_EXECUTABLES)/AdbWinApi.dll \
- $(HOST_OUT_EXECUTABLES)/AdbWinUsbApi.dll
-endif
-
-
-# adbd device daemon
-# =========================================================
-
-# build adbd in all non-simulator builds
-BUILD_ADBD := false
-ifneq ($(TARGET_SIMULATOR),true)
- BUILD_ADBD := true
-endif
-
-# build adbd for the Linux simulator build
-# so we can use it to test the adb USB gadget driver on x86
-#ifeq ($(HOST_OS),linux)
-# BUILD_ADBD := true
-#endif
-
-
-ifeq ($(BUILD_ADBD),true)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- adb.c \
- fdevent.c \
- transport.c \
- transport_local.c \
- transport_usb.c \
- sockets.c \
- services.c \
- file_sync_service.c \
- jdwp_service.c \
- framebuffer_service.c \
- remount_service.c \
- usb_linux_client.c \
- log_service.c \
- utils.c
-
-LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
-LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
-
-# TODO: This should probably be board specific, whether or not the kernel has
-# the gadget driver; rather than relying on the architecture type.
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_CFLAGS += -DANDROID_GADGET=1
-endif
-
-LOCAL_MODULE := adbd
-
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
-LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
-
-ifeq ($(TARGET_SIMULATOR),true)
- LOCAL_STATIC_LIBRARIES := libcutils
- LOCAL_LDLIBS += -lpthread
- include $(BUILD_HOST_EXECUTABLE)
-else
- LOCAL_STATIC_LIBRARIES := libcutils libc
- include $(BUILD_EXECUTABLE)
-endif
-
-endif
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "android_reboot.h"
-
-/* Check to see if /proc/mounts contains any writeable filesystems
- * backed by a block device.
- * Return true if none found, else return false.
- */
-static int remount_ro_done(void)
-{
- FILE *f;
- char mount_dev[256];
- char mount_dir[256];
- char mount_type[256];
- char mount_opts[256];
- int mount_freq;
- int mount_passno;
- int match;
- int found_rw_fs = 0;
-
- f = fopen("/proc/mounts", "r");
- if (! f) {
- /* If we can't read /proc/mounts, just give up */
- return 1;
- }
-
- do {
- match = fscanf(f, "%255s %255s %255s %255s %d %d\n",
- mount_dev, mount_dir, mount_type,
- mount_opts, &mount_freq, &mount_passno);
- mount_dev[255] = 0;
- mount_dir[255] = 0;
- mount_type[255] = 0;
- mount_opts[255] = 0;
- if ((match == 6) && !strncmp(mount_dev, "/dev/block", 10) && strstr(mount_opts, "rw")) {
- found_rw_fs = 1;
- break;
- }
- } while (match != EOF);
-
- fclose(f);
-
- return !found_rw_fs;
-}
-
-/* Remounting filesystems read-only is difficult when there are files
- * opened for writing or pending deletes on the filesystem. There is
- * no way to force the remount with the mount(2) syscall. The magic sysrq
- * 'u' command does an emergency remount read-only on all writable filesystems
- * that have a block device (i.e. not tmpfs filesystems) by calling
- * emergency_remount(), which knows how to force the remount to read-only.
- * Unfortunately, that is asynchronous, and just schedules the work and
- * returns. The best way to determine if it is done is to read /proc/mounts
- * repeatedly until there are no more writable filesystems mounted on
- * block devices.
- */
-static void remount_ro(void)
-{
- int fd, cnt = 0;
- int len = 0;
- /* Trigger the remount of the filesystems as read-only,
- * which also marks them clean.
- */
- fd = open("/proc/sysrq-trigger", O_WRONLY);
- if (fd < 0) {
- return;
- }
- len = write(fd, "u", 1);
- close(fd);
-
- /* Now poll /proc/mounts till it's done */
- while (!remount_ro_done() && (cnt < 50)) {
- usleep(100000);
- cnt++;
- }
-
- return;
-}
-
-
-int android_reboot(int cmd, int flags, char *arg)
-{
- int ret;
-
- if (!(flags & ANDROID_RB_FLAG_NO_SYNC))
- sync();
-
- if (!(flags & ANDROID_RB_FLAG_NO_REMOUNT_RO))
- remount_ro();
-
- switch (cmd) {
- case ANDROID_RB_RESTART:
- ret = reboot(RB_AUTOBOOT);
- break;
-
- case ANDROID_RB_POWEROFF:
- ret = reboot(RB_POWER_OFF);
- break;
-#if 0 /* tizen specific */
- case ANDROID_RB_RESTART2:
- ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
- LINUX_REBOOT_CMD_RESTART2, arg);
- break;
-#endif
- default:
- ret = -1;
- }
-
- return ret;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __CUTILS_ANDROID_REBOOT_H__
-#define __CUTILS_ANDROID_REBOOT_H__
-
-__BEGIN_DECLS
-
-/* Commands */
-#define ANDROID_RB_RESTART 0xDEAD0001
-#define ANDROID_RB_POWEROFF 0xDEAD0002
-#define ANDROID_RB_RESTART2 0xDEAD0003
-
-/* Flags */
-#define ANDROID_RB_FLAG_NO_SYNC 0x1
-#define ANDROID_RB_FLAG_NO_REMOUNT_RO 0x2
-
-int android_reboot(int cmd, int flags, char *arg);
-
-__END_DECLS
-
-#endif /* __CUTILS_ANDROID_REBOOT_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include "fdevent.h"
-#include "sdb.h"
-
-#include <linux/fb.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-
-/* TODO:
-** - sync with vsync to avoid tearing
-*/
-/* This version number defines the format of the fbinfo struct.
- It must match versioning in ddms where this data is consumed. */
-#define DDMS_RAWIMAGE_VERSION 1
-struct fbinfo {
- unsigned int version;
- unsigned int bpp;
- unsigned int size;
- unsigned int width;
- unsigned int height;
- unsigned int red_offset;
- unsigned int red_length;
- unsigned int blue_offset;
- unsigned int blue_length;
- unsigned int green_offset;
- unsigned int green_length;
- unsigned int alpha_offset;
- unsigned int alpha_length;
-} __attribute__((packed));
-
-void framebuffer_service(int fd, void *cookie)
-{
- struct fbinfo fbinfo;
- unsigned int i;
- char buf[640];
- int fd_screencap;
- int w, h, f;
- int fds[2];
- pid_t pid = 0;
-
- if (pipe(fds) < 0) goto done;
-
- pid = fork();
- if (pid < 0) goto done;
-
- if (pid == 0) {
- dup2(fds[1], STDOUT_FILENO);
- close(fds[0]);
- close(fds[1]);
- const char* command = "screencap";
- const char *args[2] = {command, NULL};
- execvp(command, (char**)args);
- exit(1);
- }
-
- fd_screencap = fds[0];
-
- /* read w, h & format */
- if(readx(fd_screencap, &w, 4)) goto done;
- if(readx(fd_screencap, &h, 4)) goto done;
- if(readx(fd_screencap, &f, 4)) goto done;
-
- fbinfo.version = DDMS_RAWIMAGE_VERSION;
- /* see hardware/hardware.h */
- switch (f) {
- case 1: /* RGBA_8888 */
- fbinfo.bpp = 32;
- fbinfo.size = w * h * 4;
- fbinfo.width = w;
- fbinfo.height = h;
- fbinfo.red_offset = 0;
- fbinfo.red_length = 8;
- fbinfo.green_offset = 8;
- fbinfo.green_length = 8;
- fbinfo.blue_offset = 16;
- fbinfo.blue_length = 8;
- fbinfo.alpha_offset = 24;
- fbinfo.alpha_length = 8;
- break;
- case 2: /* RGBX_8888 */
- fbinfo.bpp = 32;
- fbinfo.size = w * h * 4;
- fbinfo.width = w;
- fbinfo.height = h;
- fbinfo.red_offset = 0;
- fbinfo.red_length = 8;
- fbinfo.green_offset = 8;
- fbinfo.green_length = 8;
- fbinfo.blue_offset = 16;
- fbinfo.blue_length = 8;
- fbinfo.alpha_offset = 24;
- fbinfo.alpha_length = 0;
- break;
- case 3: /* RGB_888 */
- fbinfo.bpp = 24;
- fbinfo.size = w * h * 3;
- fbinfo.width = w;
- fbinfo.height = h;
- fbinfo.red_offset = 0;
- fbinfo.red_length = 8;
- fbinfo.green_offset = 8;
- fbinfo.green_length = 8;
- fbinfo.blue_offset = 16;
- fbinfo.blue_length = 8;
- fbinfo.alpha_offset = 24;
- fbinfo.alpha_length = 0;
- break;
- case 4: /* RGB_565 */
- fbinfo.bpp = 16;
- fbinfo.size = w * h * 2;
- fbinfo.width = w;
- fbinfo.height = h;
- fbinfo.red_offset = 11;
- fbinfo.red_length = 5;
- fbinfo.green_offset = 5;
- fbinfo.green_length = 6;
- fbinfo.blue_offset = 0;
- fbinfo.blue_length = 5;
- fbinfo.alpha_offset = 0;
- fbinfo.alpha_length = 0;
- break;
- case 5: /* BGRA_8888 */
- fbinfo.bpp = 32;
- fbinfo.size = w * h * 4;
- fbinfo.width = w;
- fbinfo.height = h;
- fbinfo.red_offset = 16;
- fbinfo.red_length = 8;
- fbinfo.green_offset = 8;
- fbinfo.green_length = 8;
- fbinfo.blue_offset = 0;
- fbinfo.blue_length = 8;
- fbinfo.alpha_offset = 24;
- fbinfo.alpha_length = 8;
- break;
- default:
- goto done;
- }
-
- /* write header */
- if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;
-
- /* write data */
- for(i = 0; i < fbinfo.size; i += sizeof(buf)) {
- if(readx(fd_screencap, buf, sizeof(buf))) goto done;
- if(writex(fd, buf, sizeof(buf))) goto done;
- }
- if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done;
- if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done;
-
-done:
- TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
-
- close(fds[0]);
- close(fds[1]);
- close(fd);
-}
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/mount.h>
-#include <errno.h>
-
-#include "sysdeps.h"
-
-#define TRACE_TAG TRACE_SDB
-#include "sdb.h"
-
-/* remount service is not supported yet */
-#if 0
-static int system_ro = 1;
-
-/* Returns the device used to mount a directory in /proc/mounts */
-static char *find_mount(const char *dir)
-{
- int fd;
- int res;
- int size;
- char *token = NULL;
- const char delims[] = "\n";
- char buf[4096];
-
- fd = unix_open("/proc/mounts", O_RDONLY);
- if (fd < 0) {
- return NULL;
- }
-
- buf[sizeof(buf) - 1] = '\0';
- size = sdb_read(fd, buf, sizeof(buf) - 1);
- sdb_close(fd);
-
- token = strtok(buf, delims);
-
- while (token) {
- char mount_dev[256];
- char mount_dir[256];
- int mount_freq;
- int mount_passno;
-
- res = sscanf(token, "%255s %255s %*s %*s %d %d\n",
- mount_dev, mount_dir, &mount_freq, &mount_passno);
- mount_dev[255] = 0;
- mount_dir[255] = 0;
- if (res == 4 && (strcmp(dir, mount_dir) == 0))
- return strdup(mount_dev);
-
- token = strtok(NULL, delims);
- }
- return NULL;
-}
-
-/* Init mounts /system as read only, remount to enable writes. */
-static int remount_system()
-{
- char *dev;
-
- if (system_ro == 0) {
- return 0;
- }
-
- dev = find_mount("/system");
-
- if (!dev)
- return -1;
-
- system_ro = mount(dev, "/system", "none", MS_REMOUNT, NULL);
-
- free(dev);
-
- return system_ro;
-}
-
-static void write_string(int fd, const char* str)
-{
- writex(fd, str, strlen(str));
-}
-
-void remount_service(int fd, void *cookie)
-{
- int ret = remount_system();
-
- if (!ret)
- write_string(fd, "remount succeeded\n");
- else {
- char buffer[200];
- snprintf(buffer, sizeof(buffer), "remount failed: %s\n", strerror(errno));
- write_string(fd, buffer);
- }
-
- sdb_close(fd);
-}
-#endif
# include <sys/ioctl.h>
# endif
#else
-# include "android_reboot.h"
# include <sys/inotify.h>
# include "sdktools.h"
#endif