@SuppressLint("NewApi" /* Since Android R(30) */)
        private void onKillMessage(Message msg) {
            XLog.i("AppExitInfoTrackerHooks onKillMessage: %s", msg);

            if (MSG_PROC_DIED == msg.what) {
                ApplicationExitInfo applicationExitInfo = (ApplicationExitInfo) msg.obj;
                ProcessRecord pr = new ProcessRecord(
                        applicationExitInfo.getPackageName(),
                        applicationExitInfo.getProcessName(),
                        applicationExitInfo.getPid(),
                        applicationExitInfo.getPackageUid(),
                        false, false);
                BootStrap.THANOS_X.getActivityManagerService().onProcessRemoved(pr);
            }
        }
We use this hook to track app process kill event and report to thanox service.
Tested on Android12.
android/android_framework/patch-magisk/patch-framework/src/main/java/github/tornaco/thanox/android/server/patch/framework/hooks/am/AppExitInfoTrackerHooks.java