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

Commit cb4e53d7 authored by Ryuichiro Chiba's avatar Ryuichiro Chiba
Browse files

Support native processes in the AMS

This CL introduces native process support in the ActivityManager behind
an aconfig flag.

Bug: 402614577
Test: build and run cuttlefish
Flag: android.os.native_framework_prototype

Change-Id: I4d13cb6e40406bcbade6dad189e26f0506779e00
parent c465946b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -207,6 +207,7 @@ interface IActivityManager {
    oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
            boolean abortBroadcast, int flags);
    void attachApplication(in IApplicationThread app, long startSeq);
    void attachNativeApplication(in IBinder nativeThread, long startSeq);
    void finishAttachApplication(long startSeq, long timestampApplicationOnCreateNs);
    List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
    @UnsupportedAppUsage
+24 −0
Original line number Diff line number Diff line
@@ -92,4 +92,28 @@ interface IActivityManagerStructured {
    void unregisterProcessObserver(in IProcessObserver observer);
    @UnsupportedAppUsage
    List<RunningAppProcessInfo> getRunningAppProcesses();

    /** Callback from a service to AMS to indicate it has completed a scheduled operation */
    @UnsupportedAppUsage
    oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
    /** Type for IActivityManager.serviceDoneExecuting: anonymous operation */
    const int SERVICE_DONE_EXECUTING_ANON = 0;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onStart call */
    const int SERVICE_DONE_EXECUTING_START = 1;
    /** Type for IActivityManager.serviceDoneExecuting: done stopping (destroying) service */
    const int SERVICE_DONE_EXECUTING_STOP = 2;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onRebind call */
    const int SERVICE_DONE_EXECUTING_REBIND = 3;
    /** Type for IActivityManager.serviceDoneExecuting: done with an onUnbind call */
    const int SERVICE_DONE_EXECUTING_UNBIND = 4;

    /** A service reporting that it has completed a binding, and returning the IBinder */
    void publishService(in IBinder token, in IBinder bindToken, in IBinder service);

    /** A service reporting that it has completed an unbind operation */
    void unbindFinished(in IBinder token, in IBinder bindToken);

    void attachNativeApplication(in IBinder nativeThread, long startSeq);

    void finishAttachApplication(long startSeq, long timestampApplicationOnCreateNs);
}
+7 −0
Original line number Diff line number Diff line
@@ -333,6 +333,13 @@ flag {
     is_fixed_read_only: true
}

flag {
    name: "native_framework_prototype"
    namespace: "system_performance"
    description: "Enable support for the native framework prototype"
    bug: "406925781"
}

flag {
    name: "network_time_uses_shared_memory"
    namespace: "system_performance"
+19 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ import android.app.IApplicationStartInfoCompleteListener;
import android.app.IApplicationThread;
import android.app.IForegroundServiceObserver;
import android.app.IInstrumentationWatcher;
import android.app.INativeApplicationThread;
import android.app.INotificationManager;
import android.app.IProcessObserver;
import android.app.IServiceConnection;
@@ -4913,6 +4914,24 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    @Override
    public final void attachNativeApplication(IBinder nativeThread, long startSeq) {
        if (!android.os.Flags.nativeFrameworkPrototype()) {
            throw new SecurityException("Unsupported application interface");
        }
        if (nativeThread == null) {
            throw new SecurityException("Null application interface");
        }
        final INativeApplicationThread thread =
                INativeApplicationThread.Stub.asInterface(nativeThread);
        if (thread == null) {
            throw new SecurityException("Invalid application interface");
        }
        NativeApplicationThreadWrapper wrapper = new NativeApplicationThreadWrapper(
                thread, this, Binder.getCallingUid(), startSeq);
        attachApplication(wrapper, startSeq);
    }
    private void finishAttachApplicationInner(long startSeq, int uid, int pid) {
        final long startTime = SystemClock.uptimeMillis();
        // Find the application record that is being attached...  either via
+29 −0
Original line number Diff line number Diff line
@@ -126,4 +126,33 @@ final class ActivityManagerStructured extends IActivityManagerStructured.Stub {
        }
        return appList;
    }

    @Override
    public void serviceDoneExecuting(IBinder token, int type, int startId, int res)
            throws RemoteException {
        mAm.serviceDoneExecuting(token, type, startId, res);
    }

    @Override
    public void publishService(IBinder token, IBinder bindToken, android.os.IBinder service)
            throws RemoteException {
        mAm.publishService(token, bindToken, service);
    }

    @Override
    public void unbindFinished(IBinder token, IBinder bindToken) throws RemoteException {
        mAm.unbindFinished(token, bindToken);
    }

    @Override
    public void attachNativeApplication(IBinder nativeThread, long startSeq)
            throws RemoteException {
        mAm.attachNativeApplication(nativeThread, startSeq);
    }

    @Override
    public void finishAttachApplication(long startSeq, long timestampApplicationOnCreateNs)
            throws RemoteException {
        mAm.finishAttachApplication(startSeq, timestampApplicationOnCreateNs);
    }
}
Loading