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

Commit 19fff421 authored by Anh Nguyen's avatar Anh Nguyen
Browse files

Merge tag 'android-5.1.0_r1' into HEAD

Android 5.1.0 release 1

Conflicts:
	cmds/atrace/atrace.cpp
	include/media/openmax/OMX_Audio.h
	services/surfaceflinger/Layer.cpp
	services/surfaceflinger/Layer.h
	services/surfaceflinger/SurfaceFlinger.cpp
	services/surfaceflinger/SurfaceFlinger.h

Change-Id: I090bc3c6d46cb853289b449b2e5f234ff950437d
parents bdeb67fd 796aaf7f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@

PRODUCT_PROPERTY_OVERRIDES += \
    dalvik.vm.heapstartsize=8m \
    dalvik.vm.heapgrowthlimit=64m \
    dalvik.vm.heapgrowthlimit=80m \
    dalvik.vm.heapsize=384m \
    dalvik.vm.heaptargetutilization=0.75 \
    dalvik.vm.heapminfree=512k \
+9 −9
Original line number Diff line number Diff line
@@ -106,14 +106,14 @@ static const TracingCategory k_categories[] = {
        { REQ,      "/sys/kernel/debug/tracing/events/power/cpu_idle/enable" },
    } },
    { "disk",       "Disk I/O",         0, {
        { REQ,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_enter/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_exit/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_begin/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_end/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_begin/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_end/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_enter/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_sync_file_exit/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_begin/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/f2fs/f2fs_write_end/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_begin/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_da_write_end/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_enter/enable" },
        { OPT,      "/sys/kernel/debug/tracing/events/ext4/ext4_sync_file_exit/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/block/block_rq_issue/enable" },
        { REQ,      "/sys/kernel/debug/tracing/events/block/block_rq_complete/enable" },
    } },
+25 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -75,6 +76,28 @@ static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) {
    }
}

static void dump_dev_files(const char *title, const char *driverpath, const char *filename)
{
    DIR *d;
    struct dirent *de;
    char path[PATH_MAX];

    d = opendir(driverpath);
    if (d == NULL) {
        return;
    }

    while ((de = readdir(d))) {
        if (de->d_type != DT_LNK) {
            continue;
        }
        snprintf(path, sizeof(path), "%s/%s/%s", driverpath, de->d_name, filename);
        dump_file(title, path);
    }

    closedir(d);
}

/* dumps the current system state to stdout */
static void dumpstate() {
    time_t now = time(NULL);
@@ -107,7 +130,9 @@ static void dumpstate() {
    printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
    printf("\n");

    dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
    run_command("UPTIME", 10, "uptime", NULL);
    dump_file("MMC PERF", "/sys/block/mmcblk0/stat");
    dump_file("MEMORY INFO", "/proc/meminfo");
    run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-t", NULL);
    run_command("PROCRANK", 20, "procrank", NULL);
@@ -270,9 +295,6 @@ static void dumpstate() {

    run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL);

    run_command("PACKAGE SETTINGS", 20, SU_PATH, "root", "cat", "/data/system/packages.xml", NULL);
    dump_file("PACKAGE UID ERRORS", "/data/system/uiderrors.txt");

    run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL);

    printf("------ BACKLIGHTS ------\n");
+14 −6
Original line number Diff line number Diff line
@@ -360,7 +360,7 @@ int run_command(const char *title, int timeout_seconds, const char *command, ...
        }

        if (timeout_seconds && elapsed / NANOS_PER_SEC > timeout_seconds) {
            printf("*** %s: Timed out after %ds (killing pid %d)\n", command, (int) elapsed, pid);
            printf("*** %s: Timed out after %.3fs (killing pid %d)\n", command, (float) elapsed / NANOS_PER_SEC, pid);
            kill(pid, SIGTERM);
            return -1;
        }
@@ -619,20 +619,28 @@ const char *dump_traces() {
            if (lseek(fd, 0, SEEK_END) < 0) {
                fprintf(stderr, "lseek: %s\n", strerror(errno));
            } else {
                snprintf(data, sizeof(data), "[dump dalvik stack %d: %.3fs elapsed]\n",
                dprintf(fd, "[dump dalvik stack %d: %.3fs elapsed]\n",
                        pid, (float)(nanotime() - start) / NANOS_PER_SEC);
                write(fd, data, strlen(data));
            }
        } else if (should_dump_native_traces(data)) {
            /* dump native process if appropriate */
            if (lseek(fd, 0, SEEK_END) < 0) {
                fprintf(stderr, "lseek: %s\n", strerror(errno));
            } else {
                static uint16_t timeout_failures = 0;
                int64_t start = nanotime();
                dump_backtrace_to_file(pid, fd);
                snprintf(data, sizeof(data), "[dump native stack %d: %.3fs elapsed]\n",

                /* If 3 backtrace dumps fail in a row, consider debuggerd dead. */
                if (timeout_failures == 3) {
                    dprintf(fd, "too many stack dump failures, skipping...\n");
                } else if (dump_backtrace_to_file_timeout(pid, fd, 20) == -1) {
                    dprintf(fd, "dumping failed, likely due to a timeout\n");
                    timeout_failures++;
                } else {
                    timeout_failures = 0;
                }
                dprintf(fd, "[dump native stack %d: %.3fs elapsed]\n",
                        pid, (float)(nanotime() - start) / NANOS_PER_SEC);
                write(fd, data, strlen(data));
            }
        }
    }
+81 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <cutils/sched_policy.h>
#include <diskusage/dirsize.h>
#include <selinux/android.h>
#include <system/thread_defs.h>

/* Directory records that are used in execution of commands. */
dir_rec_t android_data_dir;
@@ -687,7 +688,7 @@ static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name,
}

static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    const char* output_file_name, const char *pkgname, const char *instruction_set,
    const char* output_file_name, int swap_fd, const char *pkgname, const char *instruction_set,
    bool vm_safe_mode)
{
    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
@@ -745,6 +746,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    char dex2oat_Xms_arg[strlen("-Xms") + PROPERTY_VALUE_MAX];
    char dex2oat_Xmx_arg[strlen("-Xmx") + PROPERTY_VALUE_MAX];
    char dex2oat_compiler_filter_arg[strlen("--compiler-filter=") + PROPERTY_VALUE_MAX];
    bool have_dex2oat_swap_fd = false;
    char dex2oat_swap_fd[strlen("--swap-fd=") + MAX_INT_LEN];

    sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
    sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
@@ -752,6 +755,10 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
    sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
    sprintf(instruction_set_features_arg, "--instruction-set-features=%s", dex2oat_isa_features);
    if (swap_fd >= 0) {
        have_dex2oat_swap_fd = true;
        sprintf(dex2oat_swap_fd, "--swap-fd=%d", swap_fd);
    }

    bool have_profile_file = false;
    bool have_top_k_profile_threshold = false;
@@ -796,7 +803,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
               + (have_dex2oat_Xms_flag ? 2 : 0)
               + (have_dex2oat_Xmx_flag ? 2 : 0)
               + (have_dex2oat_compiler_filter_flag ? 1 : 0)
               + (have_dex2oat_flags ? 1 : 0)];
               + (have_dex2oat_flags ? 1 : 0)
               + (have_dex2oat_swap_fd ? 1 : 0)];
    int i = 0;
    argv[i++] = (char*)DEX2OAT_BIN;
    argv[i++] = zip_fd_arg;
@@ -827,6 +835,9 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name,
    if (have_dex2oat_flags) {
        argv[i++] = dex2oat_flags;
    }
    if (have_dex2oat_swap_fd) {
        argv[i++] = dex2oat_swap_fd;
    }
    // Do not add after dex2oat_flags, they should override others for debugging.
    argv[i] = NULL;

@@ -860,6 +871,23 @@ static int wait_child(pid_t pid)
    }
}

/*
 * Whether dexopt should use a swap file when compiling an APK. If kAlwaysProvideSwapFile, do this
 * on all devices (dex2oat will make a more informed decision itself, anyways). Otherwise, only do
 * this on a low-mem device.
 */
static bool kAlwaysProvideSwapFile = true;

static bool ShouldUseSwapFileForDexopt() {
    if (kAlwaysProvideSwapFile) {
        return true;
    }

    char low_mem_buf[PROPERTY_VALUE_MAX];
    property_get("ro.config.low_ram", low_mem_buf, "");
    return (strcmp(low_mem_buf, "true") == 0);
}

int dexopt(const char *apk_path, uid_t uid, bool is_public,
           const char *pkgname, const char *instruction_set,
           bool vm_safe_mode, bool is_patchoat)
@@ -868,11 +896,15 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
    struct stat input_stat, dex_stat;
    char out_path[PKG_PATH_MAX];
    char persist_sys_dalvik_vm_lib[PROPERTY_VALUE_MAX];
    char swap_file_name[PKG_PATH_MAX];
    char *end;
    const char *input_file;
    char in_odex_path[PKG_PATH_MAX];
    int res, input_fd=-1, out_fd=-1;
    int res, input_fd=-1, out_fd=-1, swap_fd=-1;

    // Early best-effort check whether we can fit the the path into our buffers.
    // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run
    // without a swap file, if necessary.
    if (strlen(apk_path) >= (PKG_PATH_MAX - 8)) {
        return -1;
    }
@@ -956,6 +988,28 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
        create_profile_file(pkgname, uid);
    }

    // Create a swap file if necessary.
    if (!is_patchoat && ShouldUseSwapFileForDexopt()) {
        // Make sure there really is enough space.
        size_t out_len = strlen(out_path);
        if (out_len + strlen(".swap") + 1 <= PKG_PATH_MAX) {
            strcpy(swap_file_name, out_path);
            strcpy(swap_file_name + strlen(out_path), ".swap");
            unlink(swap_file_name);
            swap_fd = open(swap_file_name, O_RDWR | O_CREAT | O_EXCL, 0600);
            if (swap_fd < 0) {
                // Could not create swap file. Optimistically go on and hope that we can compile
                // without it.
                ALOGE("installd could not create '%s' for swap during dexopt\n", swap_file_name);
            } else {
                // Immediately unlink. We don't really want to hit flash.
                unlink(swap_file_name);
            }
        } else {
            // Swap file path is too long. Try to run without.
            ALOGE("installd could not create swap file for path %s during dexopt\n", out_path);
        }
    }

    ALOGV("DexInv: --- BEGIN '%s' ---\n", input_file);

@@ -985,6 +1039,10 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
            ALOGE("set_sched_policy failed: %s\n", strerror(errno));
            exit(70);
        }
        if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) {
            ALOGE("setpriority failed: %s\n", strerror(errno));
            exit(71);
        }
        if (flock(out_fd, LOCK_EX | LOCK_NB) != 0) {
            ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno));
            exit(67);
@@ -996,8 +1054,8 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
            if (is_patchoat) {
                run_patchoat(input_fd, out_fd, input_file, out_path, pkgname, instruction_set);
            } else {
                run_dex2oat(input_fd, out_fd, input_file, out_path, pkgname, instruction_set,
                            vm_safe_mode);
                run_dex2oat(input_fd, out_fd, input_file, out_path, swap_fd, pkgname,
                            instruction_set, vm_safe_mode);
            }
        } else {
            exit(69);   /* Unexpected persist.sys.dalvik.vm.lib value */
@@ -1019,6 +1077,9 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,

    close(out_fd);
    close(input_fd);
    if (swap_fd != -1) {
        close(swap_fd);
    }
    return 0;

fail:
@@ -1032,6 +1093,21 @@ fail:
    return -1;
}

int mark_boot_complete(const char* instruction_set)
{
  char boot_marker_path[PKG_PATH_MAX];
  sprintf(boot_marker_path,"%s%s/.booting", DALVIK_CACHE_PREFIX, instruction_set);

  ALOGV("mark_boot_complete : %s", boot_marker_path);
  if (unlink(boot_marker_path) != 0) {
      ALOGE("Unable to unlink boot marker at %s, error=%s", boot_marker_path,
            strerror(errno));
      return -1;
  }

  return 0;
}

void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid,
        struct stat* statbuf)
{
Loading