summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Suren Baghdasaryan <surenb@google.com> 2019-12-23 13:38:53 -0800
committer Suren Baghdasaryan <surenb@google.com> 2019-12-23 13:39:45 -0800
commitb6b8d1d8faa240130b74ddeb097a5284aa39d11e (patch)
tree41f7f175faa27c4916b22992758e827d57f2fdd2
parent888365c03dd132d0c058f190118c7577e5e96001 (diff)
Subscribe ActivityManagerService to receive lmkd kill notifications
With new LMK_SUBSCRIBE lmkd command clients need to subscribe for lmkd notifications. Bug: 146597855 Test: run lmkd_unit_test and verify kill notification delivery Change-Id: Ib54647ce36426a56db3ab6f95f375a0a0ce352ce Signed-off-by: Suren Baghdasaryan <surenb@google.com>
-rw-r--r--services/core/java/com/android/server/am/ProcessList.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 3b8d39bf7a19..f5579761c151 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -246,20 +246,27 @@ public final class ProcessList {
"persist.device_config.runtime_native.use_app_image_startup_cache";
// Low Memory Killer Daemon command codes.
- // These must be kept in sync with the definitions in lmkd.c
+ // These must be kept in sync with lmk_cmd definitions in lmkd.h
//
// LMK_TARGET <minfree> <minkillprio> ... (up to 6 pairs)
// LMK_PROCPRIO <pid> <uid> <prio>
// LMK_PROCREMOVE <pid>
// LMK_PROCPURGE
// LMK_GETKILLCNT
+ // LMK_SUBSCRIBE
// LMK_PROCKILL
static final byte LMK_TARGET = 0;
static final byte LMK_PROCPRIO = 1;
static final byte LMK_PROCREMOVE = 2;
static final byte LMK_PROCPURGE = 3;
static final byte LMK_GETKILLCNT = 4;
- static final byte LMK_PROCKILL = 5; // Note: this is an unsolicated command
+ static final byte LMK_SUBSCRIBE = 5;
+ static final byte LMK_PROCKILL = 6; // Note: this is an unsolicated command
+
+ // Low Memory Killer Daemon command codes.
+ // These must be kept in sync with async_event_type definitions in lmkd.h
+ //
+ static final int LMK_ASYNC_EVENT_KILL = 0;
// lmkd reconnect delay in msecs
private static final long LMKD_RECONNECT_DELAY_MS = 1000;
@@ -1308,6 +1315,11 @@ public final class ProcessList {
}
ostream.write(buf.array(), 0, buf.position());
}
+ // Subscribe for kill event notifications
+ buf = ByteBuffer.allocate(4 * 2);
+ buf.putInt(LMK_SUBSCRIBE);
+ buf.putInt(LMK_ASYNC_EVENT_KILL);
+ ostream.write(buf.array(), 0, buf.position());
} catch (IOException ex) {
return false;
}