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

Commit d6863d2e authored by Lee Shombert's avatar Lee Shombert
Browse files

Use the standard AIDL Delegator

Use the supported IApplicationThread.Delegator class instead of the
one-off ApplicationThreadFilter.  The Delegator class is created by
adding the @JavaDelegator annnotation to the IApplicationThread.aidl
specification.

ApplicationThreadDeferred extends IApplicationThread.Delegator with
one important change from normal Delegator use: the asBinder() method
must be overridden in this case.

Test: atest
 * FrameworksServicesTests:com.android.server.am
 * FrameworksMockingServicesTests:com.android.server.am

Flag: com.android.server.am.defer_binders_when_paused
Bug: 327038797
Change-Id: Idc08df00a99521b7cbb3e54dc2045ddbaadaa67b
parent 62733fb8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import java.util.Map;
 *
 * {@hide}
 */
@JavaDelegator
oneway interface IApplicationThread {
    void scheduleReceiver(in Intent intent, in ActivityInfo info,
            in CompatibilityInfo compatInfo,
+14 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import java.util.Arrays;
 *
 * {@hide}
 */
class ApplicationThreadDeferred extends ApplicationThreadFilter {
final class ApplicationThreadDeferred extends IApplicationThread.Delegator {

    static final String TAG = TAG_WITH_CLASS_NAME ? "ApplicationThreadDeferred" : TAG_AM;

@@ -87,11 +87,15 @@ class ApplicationThreadDeferred extends ApplicationThreadFilter {
    // When true, binder calls to paused processes will be deferred until the process is unpaused.
    private final boolean mDefer;

    // The base thread, because Delegator does not expose it.
    private final IApplicationThread mBase;

    /** Create an instance with a base thread and a deferral enable flag. */
    @VisibleForTesting
    public ApplicationThreadDeferred(IApplicationThread thread, boolean defer) {
        super(thread);

        mBase = thread;
        mDefer = defer;

        mOperations[CLEAR_DNS_CACHE] = () -> { super.clearDnsCache(); };
@@ -105,6 +109,15 @@ class ApplicationThreadDeferred extends ApplicationThreadFilter {
        this(thread, deferBindersWhenPaused());
    }

    /**
     * Return the implementation's value of asBinder(). super.asBinder() is not a real Binder
     * object.
     */
    @Override
    public  android.os.IBinder asBinder() {
        return mBase.asBinder();
    }

    /** The process is being paused.  Start deferring calls. */
    void onProcessPaused() {
        synchronized (mLock) {
+0 −603

File deleted.

Preview size limit exceeded, changes collapsed.