Merge "Remove nvram trusty implementation." into oc-mr1-dev
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index e0629ab..3ecbc44 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -239,8 +239,8 @@
adb_device_banner = optarg;
break;
case 'v':
- printf("Android Debug Bridge Daemon version %d.%d.%d (%s)\n", ADB_VERSION_MAJOR,
- ADB_VERSION_MINOR, ADB_SERVER_VERSION, ADB_VERSION);
+ printf("Android Debug Bridge Daemon version %d.%d.%d\n", ADB_VERSION_MAJOR,
+ ADB_VERSION_MINOR, ADB_SERVER_VERSION);
return 0;
default:
// getopt already prints "adbd: invalid option -- %c" for us.
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index 55cd03e..1275229 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -116,6 +116,26 @@
fatal("%s: %s", buf, strerror(err));
}
+static bool get_main_thread_name(char* buf, size_t len) {
+ int fd = open("/proc/self/comm", O_RDONLY | O_CLOEXEC);
+ if (fd == -1) {
+ return false;
+ }
+
+ ssize_t rc = read(fd, buf, len);
+ close(fd);
+ if (rc == -1) {
+ return false;
+ } else if (rc == 0) {
+ // Should never happen?
+ return false;
+ }
+
+ // There's a trailing newline, replace it with a NUL.
+ buf[rc - 1] = '\0';
+ return true;
+}
+
/*
* Writes a summary of the signal to the log file. We do this so that, if
* for some reason we're not able to contact debuggerd, there is still some
@@ -188,8 +208,14 @@
}
}
- async_safe_format_log(ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s)",
- signum, signal_name, code_desc, addr_desc, __gettid(), thread_name);
+ char main_thread_name[MAX_TASK_NAME_LEN + 1];
+ if (!get_main_thread_name(main_thread_name, sizeof(main_thread_name))) {
+ strncpy(main_thread_name, "<unknown>", sizeof(main_thread_name));
+ }
+
+ async_safe_format_log(
+ ANDROID_LOG_FATAL, "libc", "Fatal signal %d (%s)%s%s in tid %d (%s), pid %d (%s)", signum,
+ signal_name, code_desc, addr_desc, __gettid(), thread_name, __getpid(), main_thread_name);
}
/*
diff --git a/libsync/Android.bp b/libsync/Android.bp
index 1cd5230..ce9e84a 100644
--- a/libsync/Android.bp
+++ b/libsync/Android.bp
@@ -22,13 +22,15 @@
cc_library_shared {
name: "libsync",
- vendor_available: true,
- vndk: {
- enabled: true,
- },
defaults: ["libsync_defaults"],
}
+llndk_library {
+ name: "libsync",
+ symbol_file: "libsync.map.txt",
+ export_include_dirs: ["include"],
+}
+
// libsync_recovery is only intended for the recovery binary.
// Future versions of the kernel WILL require an updated libsync, and will break
// anything statically linked against the current libsync.
diff --git a/libsync/libsync.map.txt b/libsync/libsync.map.txt
index f9057bd..53bb07a 100644
--- a/libsync/libsync.map.txt
+++ b/libsync/libsync.map.txt
@@ -19,14 +19,10 @@
sync_merge; # introduced=26
sync_file_info; # introduced=26
sync_file_info_free; # introduced=26
+ sync_wait; # vndk
+ sync_fence_info; # vndk
+ sync_pt_info; # vndk
+ sync_fence_info_free; # vndk
local:
*;
};
-
-LIBSYNC_PLATFORM {
- global:
- sync_wait;
- sync_fence_info;
- sync_pt_info;
- sync_fence_info_free;
-} LIBSYNC_PLATFORM;
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index 27cc91b..02a9601 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -75,6 +75,7 @@
static int medium_oomadj;
static int critical_oomadj;
+static int debug_process_killing;
/* control socket listen and data */
static int ctrl_lfd;
@@ -262,7 +263,9 @@
} else if (oomadj >= 700) {
soft_limit_mult = 0;
} else if (oomadj >= 600) {
- soft_limit_mult = 0;
+ // Launcher should be perceptible, don't kill it.
+ oomadj = 200;
+ soft_limit_mult = 1;
} else if (oomadj >= 500) {
soft_limit_mult = 0;
} else if (oomadj >= 400) {
@@ -576,9 +579,7 @@
}
/* Kill one process specified by procp. Returns the size of the process killed */
-static int kill_one_process(struct proc *procp, int other_free, int other_file,
- int minfree, int min_score_adj, bool first)
-{
+static int kill_one_process(struct proc* procp, int min_score_adj, bool is_critical) {
int pid = procp->pid;
uid_t uid = procp->uid;
char *taskname;
@@ -597,12 +598,11 @@
return -1;
}
- ALOGI("Killing '%s' (%d), uid %d, adj %d\n"
- " to free %ldkB because cache %s%ldkB is below limit %ldkB for oom_adj %d\n"
- " Free memory is %s%ldkB %s reserved",
- taskname, pid, uid, procp->oomadj, tasksize * page_k,
- first ? "" : "~", other_file * page_k, minfree * page_k, min_score_adj,
- first ? "" : "~", other_free * page_k, other_free >= 0 ? "above" : "below");
+ ALOGI(
+ "Killing '%s' (%d), uid %d, adj %d\n"
+ " to free %ldkB because system is under %s memory pressure oom_adj %d\n",
+ taskname, pid, uid, procp->oomadj, tasksize * page_k, is_critical ? "critical" : "medium",
+ min_score_adj);
r = kill(pid, SIGKILL);
pid_remove(pid);
@@ -618,10 +618,8 @@
* Find a process to kill based on the current (possibly estimated) free memory
* and cached memory sizes. Returns the size of the killed processes.
*/
-static int find_and_kill_process(int other_free, int other_file, bool first, int min_score_adj)
-{
+static int find_and_kill_process(int min_score_adj, bool is_critical) {
int i;
- int minfree = 0;
int killed_size = 0;
for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) {
@@ -631,7 +629,7 @@
procp = proc_adj_lru(i);
if (procp) {
- killed_size = kill_one_process(procp, other_free, other_file, minfree, min_score_adj, first);
+ killed_size = kill_one_process(procp, min_score_adj, is_critical);
if (killed_size < 0) {
goto retry;
} else {
@@ -646,7 +644,6 @@
static void mp_event_common(bool is_critical) {
int ret;
unsigned long long evcount;
- bool first = true;
int min_adj_score = is_critical ? critical_oomadj : medium_oomadj;
int index = is_critical ? CRITICAL_INDEX : MEDIUM_INDEX;
@@ -655,8 +652,10 @@
ALOGE("Error reading memory pressure event fd; errno=%d",
errno);
- if (find_and_kill_process(0, 0, first, min_adj_score) == 0) {
- ALOGI("Nothing to kill");
+ if (find_and_kill_process(min_adj_score, is_critical) == 0) {
+ if (debug_process_killing) {
+ ALOGI("Nothing to kill");
+ }
}
}
@@ -665,7 +664,6 @@
}
static void mp_event_critical(uint32_t events __unused) {
- ALOGI("Memory pressure critical");
mp_event_common(true);
}
@@ -828,6 +826,7 @@
medium_oomadj = property_get_int32("ro.lmk.medium", 800);
critical_oomadj = property_get_int32("ro.lmk.critical", 0);
+ debug_process_killing = property_get_bool("ro.lmk.debug", false);
mlockall(MCL_FUTURE);
sched_setscheduler(0, SCHED_FIFO, ¶m);
diff --git a/rootdir/etc/ld.config.txt b/rootdir/etc/ld.config.txt
index 79a27a0..16db770 100644
--- a/rootdir/etc/ld.config.txt
+++ b/rootdir/etc/ld.config.txt
@@ -88,7 +88,7 @@
namespace.rs.asan.permitted.paths = /data/asan/vendor/${LIB}:/vendor/${LIB}:/data
namespace.rs.links = default,vndk
-namespace.rs.link.default.shared_libs = libc.so:libm.so:libdl.so:libstdc++.so:liblog.so:libnativewindow.so:libEGL.so:libsync.so:libGLESv1_CM.so:libGLESv2.so:libmediandk.so:libvndksupport.so
+namespace.rs.link.default.shared_libs = libc.so:libm.so:libdl.so:libstdc++.so:liblog.so:libnativewindow.so:libEGL.so:libsync.so:libGLESv1_CM.so:libGLESv2.so:libmediandk.so:libvndksupport.so:libft2.so
namespace.rs.link.vndk.shared_libs = android.hardware.renderscript@1.0.so:android.hardware.graphics.allocator@2.0.so:android.hardware.graphics.mapper@2.0.so:android.hardware.graphics.common@1.0.so:android.hidl.memory@1.0.so:libhwbinder.so:libbase.so:libcutils.so:libhardware.so:libhidlbase.so:libhidlmemory.so:libhidltransport.so:libion.so:libutils.so:libc++.so:libz.so
###############################################################################