Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b9bb36a authored by Mark Salyzyn's avatar Mark Salyzyn Committed by Android Git Automerger
Browse files

am 0256e1f6: am d2acdd82: Merge changes I70ab37d5,I716f89c0,I34c96adf,I77650923,I35b0d1ee, ...

* commit '0256e1f6': (29 commits)
  libsysutils: SocketListener export release
  libsysutils: Add iovec/runOnEachSocket
  liblog: support struct logger_event_v2 format
  liblog: update timestamp on NOTICE file
  libcutils: resolve warning in iosched_policy.c
  liblog: Add const pedantics
  logcat: Add -T flag (-t w/o assumption of -d)
  logcat: Add logcat test suite
  liblog: Add cpu utilization test
  liblog: Add liblog test suite
  debuggerd: Support newline split in log messages
  liblog: deprecate export LOGGER ioctl definitions
  liblog: deprecate export of LOGGER_LOG_* defines
  liblog: Add README
  liblog: resolve build warning messages
  liblog: high CPU usage from logcat
  liblog: fix build again
  liblog: drop use of sys/cdefs.h
  liblog: git_master@964770 build problem
  logcat: Incorporate liblog reading API
  ...
parents 11322efd 0256e1f6
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -34,7 +34,7 @@ endif


ifeq ($(HOST_OS),windows)
ifeq ($(HOST_OS),windows)
  USB_SRCS := usb_windows.c
  USB_SRCS := usb_windows.c
  EXTRA_SRCS := get_my_path_windows.c ../libcutils/list.c
  EXTRA_SRCS := get_my_path_windows.c
  EXTRA_STATIC_LIBS := AdbWinApi
  EXTRA_STATIC_LIBS := AdbWinApi
  ifneq ($(strip $(USE_CYGWIN)),)
  ifneq ($(strip $(USE_CYGWIN)),)
    # Pure cygwin case
    # Pure cygwin case
@@ -114,8 +114,7 @@ LOCAL_SRC_FILES := \
	jdwp_service.c \
	jdwp_service.c \
	framebuffer_service.c \
	framebuffer_service.c \
	remount_service.c \
	remount_service.c \
	usb_linux_client.c \
	usb_linux_client.c
	log_service.c


LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
+0 −5
Original line number Original line Diff line number Diff line
@@ -198,11 +198,6 @@ localfilesystem:<path>
    Variants of local:<path> that are used to access other Android
    Variants of local:<path> that are used to access other Android
    socket namespaces.
    socket namespaces.


log:<name>
    Opens one of the system logs (/dev/log/<name>) and allows the client
    to read them directly. Used to implement 'adb logcat'. The stream
    will be read-only for the client.

framebuffer:
framebuffer:
    This service is used to send snapshots of the framebuffer to a client.
    This service is used to send snapshots of the framebuffer to a client.
    It requires sufficient privileges but works as follow:
    It requires sufficient privileges but works as follow:
+0 −2
Original line number Original line Diff line number Diff line
@@ -330,9 +330,7 @@ typedef enum {
} BackupOperation;
} BackupOperation;
int backup_service(BackupOperation operation, char* args);
int backup_service(BackupOperation operation, char* args);
void framebuffer_service(int fd, void *cookie);
void framebuffer_service(int fd, void *cookie);
void log_service(int fd, void *cookie);
void remount_service(int fd, void *cookie);
void remount_service(int fd, void *cookie);
char * get_log_file_path(const char * log_name);
#endif
#endif


/* packet allocator */
/* packet allocator */

adb/log_service.c

deleted100644 → 0
+0 −92
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * 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/socket.h>
#include <log/logger.h>
#include "sysdeps.h"
#include "adb.h"

#define LOG_FILE_DIR    "/dev/log/"

void write_log_entry(int fd, struct logger_entry *buf);

void log_service(int fd, void *cookie)
{
    /* get the name of the log filepath to read */
    char * log_filepath = cookie;

    /* open the log file. */
    int logfd = unix_open(log_filepath, O_RDONLY);
    if (logfd < 0) {
        goto done;
    }

    // temp buffer to read the entries
    unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1] __attribute__((aligned(4)));
    struct logger_entry *entry = (struct logger_entry *) buf;

    while (1) {
        int ret;

        ret = unix_read(logfd, entry, LOGGER_ENTRY_MAX_LEN);
        if (ret < 0) {
            if (errno == EINTR || errno == EAGAIN)
                continue;
            // perror("logcat read");
            goto done;
        }
        else if (!ret) {
            // fprintf(stderr, "read: Unexpected EOF!\n");
            goto done;
        }

        /* NOTE: driver guarantees we read exactly one full entry */

        entry->msg[entry->len] = '\0';

        write_log_entry(fd, entry);
    }

done:
    unix_close(fd);
    free(log_filepath);
}

/* returns the full path to the log file in a newly allocated string */
char * get_log_file_path(const char * log_name) {
    char *log_device = malloc(strlen(LOG_FILE_DIR) + strlen(log_name) + 1);

    strcpy(log_device, LOG_FILE_DIR);
    strcat(log_device, log_name);

    return log_device;
}


/* prints one log entry into the file descriptor fd */
void write_log_entry(int fd, struct logger_entry *buf)
{
    size_t size = sizeof(struct logger_entry) + buf->len;

    writex(fd, buf, size);
}
+0 −2
Original line number Original line Diff line number Diff line
@@ -368,8 +368,6 @@ int service_to_fd(const char *name)
        ret = create_service_thread(framebuffer_service, 0);
        ret = create_service_thread(framebuffer_service, 0);
    } else if (!strncmp(name, "jdwp:", 5)) {
    } else if (!strncmp(name, "jdwp:", 5)) {
        ret = create_jdwp_connection_fd(atoi(name+5));
        ret = create_jdwp_connection_fd(atoi(name+5));
    } else if (!strncmp(name, "log:", 4)) {
        ret = create_service_thread(log_service, get_log_file_path(name + 4));
    } else if(!HOST && !strncmp(name, "shell:", 6)) {
    } else if(!HOST && !strncmp(name, "shell:", 6)) {
        if(name[6]) {
        if(name[6]) {
            ret = create_subproc_thread(name + 6);
            ret = create_subproc_thread(name + 6);
Loading