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

Commit 7fdbe224 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make RemoteService propagate Context#bindService failure to PendingRequests" into qt-dev

parents ed12eb24 06f0519a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -275,6 +275,11 @@ public class RoleControllerManager {
                Log.e(LOG_TAG, "Error calling grantDefaultRoles()", e);
            }
        }

        @Override
        protected void onFailed() {
            mRemoteCallback.sendResult(null);
        }
    }

    /**
+14 −0
Original line number Diff line number Diff line
@@ -74,6 +74,20 @@ public abstract class AbstractMultiplePendingRequestsRemoteService<S
        }
    }

    @Override // from AbstractRemoteService
    final void handleBindFailure() {
        if (mPendingRequests != null) {
            final int size = mPendingRequests.size();
            if (mVerbose) Slog.v(mTag, "Sending failure to " + size + " pending requests");
            for (int i = 0; i < size; i++) {
                final BasePendingRequest<S, I> request = mPendingRequests.get(i);
                request.onFailed();
                request.finish();
            }
            mPendingRequests = null;
        }
    }

    @Override // from AbstractRemoteService
    public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
        super.dump(prefix, pw);
+13 −0
Original line number Diff line number Diff line
@@ -405,6 +405,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
    abstract void handlePendingRequestWhileUnBound(
            @NonNull BasePendingRequest<S, I> pendingRequest);

    /**
     * Called if {@link Context#bindServiceAsUser} returns {@code false}.
     */
    abstract void handleBindFailure();

    private boolean handleIsBound() {
        return mService != null;
    }
@@ -426,6 +431,8 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
            mBinding = false;

            if (!mServiceDied) {
                // TODO(b/126266412): merge these 2 calls?
                handleBindFailure();
                handleBinderDied();
            }
        }
@@ -561,6 +568,12 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I

        void onFinished() { }

        /**
         * Called when request fails due to reasons internal to {@link AbstractRemoteService},
         * e.g. failure to bind to service.
         */
        protected void onFailed() { }

        /**
         * Checks whether this request was cancelled.
         */
+9 −0
Original line number Diff line number Diff line
@@ -66,6 +66,15 @@ public abstract class AbstractSinglePendingRequestRemoteService<S
        }
    }

    @Override // from AbstractRemoteService
    void handleBindFailure() {
        if (mPendingRequest != null) {
            if (mVerbose) Slog.v(mTag, "Sending failure to " + mPendingRequest);
            mPendingRequest.onFailed();
            mPendingRequest = null;
        }
    }

    @Override // from AbstractRemoteService
    public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
        super.dump(prefix, pw);