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

Commit 46bb3e8a authored by Sanjana Sunil's avatar Sanjana Sunil
Browse files

Add a mainline-accessible API to kill an app on sandbox death

This API can be accessed by mainline modules to kill a specific app
process when its associated sandbox dies. It takes in the IBinder value
of the corresponding IApplicationThread of the app to kill it.

REASON_DEPENDENCY_DIED and SUBREASON_SDK_SANDBOX_DIED are used in the
emitted AppProcessDied atom.

Bug: 261558210
Test: atest SdkSandboxLifecycleHostTest
Test: m statsd && statsd_testdrive 373 emits an atom with
SUBREASON_SDK_SANDBOX_DIED

Change-Id: Id37023eabaa5f734bb67bee07a0f779c355cc100
parent f8849f85
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ package android.content {
  }

  public abstract class Context {
    method @NonNull public android.os.IBinder getIApplicationThreadBinder();
    method @NonNull public android.os.UserHandle getUser();
    field public static final String PAC_PROXY_SERVICE = "pac_proxy";
    field public static final String TEST_NETWORK_SERVICE = "test_network";
+9 −0
Original line number Diff line number Diff line
@@ -416,6 +416,15 @@ public final class ApplicationExitInfo implements Parcelable {
     */
    public static final int SUBREASON_UNDELIVERED_BROADCAST = 26;

    /**
     * The process was killed because its associated SDK sandbox process (where it had loaded SDKs)
     * had died; this would be set only when the reason is {@link #REASON_DEPENDENCY_DIED}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_SDK_SANDBOX_DIED = 27;

    // If there is any OEM code which involves additional app kill reasons, it should
    // be categorized in {@link #REASON_OTHER}, with subreason code starting from 1000.

+7 −0
Original line number Diff line number Diff line
@@ -1998,6 +1998,13 @@ class ContextImpl extends Context {
        return mMainThread.getApplicationThread();
    }

    /** @hide */
    @NonNull
    @Override
    public IBinder getIApplicationThreadBinder() {
        return getIApplicationThread().asBinder();
    }

    /** @hide */
    @Override
    public Handler getMainThreadHandler() {
+12 −0
Original line number Diff line number Diff line
@@ -7345,6 +7345,18 @@ public abstract class Context {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * Get the binder object associated with the IApplicationThread of this Context.
     *
     * This can be used by a mainline module to uniquely identify a specific app process.
     * @hide
     */
    @NonNull
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public IBinder getIApplicationThreadBinder() {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * @hide
     */
+8 −0
Original line number Diff line number Diff line
@@ -1247,6 +1247,14 @@ public class ContextWrapper extends Context {
        return mBase.getIApplicationThread();
    }

    /**
     * @hide
     */
    @Override
    public IBinder getIApplicationThreadBinder() {
        return mBase.getIApplicationThreadBinder();
    }

    /**
     * @hide
     */
Loading