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

Commit cbd1b501 authored by Joe Hattori's avatar Joe Hattori
Browse files

Add traces to the methods in NativeActivityThread

This commit adds atraces in NativeActivityThread methods. The tag is set
to ActivityManager, reflecting ActivityThread.java.

Test: build and confirmed traces appear on Perfetto
Flag: android.os.native_framework_prototype
Bug: 431891914
Change-Id: I82404ad81639eee5635c75ca2b84984d25c4196c
parent 44f873ed
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ rust_library {
    rustlibs: [
        "activitymanager_structured_aidl-rust",
        "libanyhow",
        "libatrace_rust",
        "libbinder_rs",
        "libdlext_bindgen",
        "liblogger",
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ use activitymanager_structured_aidl::aidl::android::app::IActivityManagerStructu
    SERVICE_DONE_EXECUTING_STOP, SERVICE_DONE_EXECUTING_UNBIND,
};
use anyhow::{bail, Context, Result};
use atrace::AtraceTag;
use binder::{
    unstable_api::{new_spibinder, AIBinder as SysAIBinder},
    SpIBinder, Strong,
@@ -68,6 +69,7 @@ impl NativeActivityThread {
    }

    fn handle_create_service_request(&mut self, req: CreateServiceRequest) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        // Create a linker namespace dedicated to the service. A process could host multiple
        // services but their namespaces must be isolated.
        let namespace = self
@@ -115,6 +117,7 @@ impl NativeActivityThread {
    }

    fn handle_destroy_service_request(&mut self, req: DestroyServiceRequest) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        // Remove the service not to process requests for it anymore.
        let mut service = self.services.remove(&req.service_token).context("service not found")?;
        if let Some(on_destroy) = service.service.callbacks.onDestroy {
@@ -129,6 +132,7 @@ impl NativeActivityThread {
    }

    fn handle_bind_service_request(&mut self, req: BindServiceRequest) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        let service = self.services.get_mut(&req.service_token).context("service not found")?;
        let intent_token = req.intent_hash;

@@ -174,6 +178,7 @@ impl NativeActivityThread {
    }

    fn handle_unbind_service_request(&mut self, req: UnbindServiceRequest) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        let service = self.services.get_mut(&req.service_token).context("service not found")?;
        let intent_token = req.intent_hash;

@@ -197,6 +202,7 @@ impl NativeActivityThread {
    }

    fn handle_trim_memory_request(&mut self, level: i32) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        if level != ANativeServiceTrimMemoryLevel_ANATIVE_SERVICE_TRIM_MEMORY_BACKGROUND
            && level != ANativeServiceTrimMemoryLevel_ANATIVE_SERVICE_TRIM_MEMORY_UI_HIDDEN
        {
@@ -218,6 +224,7 @@ impl NativeActivityThread {
    }

    fn handle_bind_application_request(&mut self) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        // We don't support calling Application.onCreate in native processes.
        self.activity_manager
            .finishAttachApplication(self.start_seq, 0)
@@ -225,6 +232,7 @@ impl NativeActivityThread {
    }

    fn handle_set_process_state(&mut self, state: i32) -> Result<()> {
        atrace::trace_method!(AtraceTag::ActivityManager);
        self.process_state = state;
        Ok(())
    }