Activity manager: native callback for process state
Make getUidProcessState() callback in IActivityManager.aidl
available to native processes.
Test: Manual test with audio recording apps pushed to background and back
to top.
Bug: 111438757
Change-Id: I16d001dcaeb3e9a38743aa7b301445c94fe5dc99
diff --git a/libs/binder/IActivityManager.cpp b/libs/binder/IActivityManager.cpp
index 428db4d..377f604 100644
--- a/libs/binder/IActivityManager.cpp
+++ b/libs/binder/IActivityManager.cpp
@@ -17,8 +17,8 @@
#include <unistd.h>
#include <fcntl.h>
+#include <binder/ActivityManager.h>
#include <binder/IActivityManager.h>
-
#include <binder/Parcel.h>
namespace android {
@@ -90,6 +90,20 @@
if (reply.readExceptionCode() != 0) return false;
return reply.readInt32() == 1;
}
+
+ virtual int32_t getUidProcessState(const uid_t uid, const String16& callingPackage)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeInt32(uid);
+ data.writeString16(callingPackage);
+ remote()->transact(GET_UID_PROCESS_STATE_TRANSACTION, data, &reply);
+ // fail on exception
+ if (reply.readExceptionCode() != 0) {
+ return ActivityManager::PROCESS_STATE_UNKNOWN;
+ }
+ return reply.readInt32();
+ }
};
// ------------------------------------------------------------------------------------