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

Commit e44d46eb authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Merge "Handle onBindingDied in AbstractRemoteService" into qt-dev

am: 08ccf9bb

Change-Id: I5e70c75119f85c6c7075fa8b583dffdf6dc523be
parents b8fc8577 08ccf9bb
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -344,13 +344,21 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
     * {@link #getTimeoutIdleBindMillis() idle timeout} expires.
     */
    protected void scheduleUnbind() {
        final long unbindDelay = getTimeoutIdleBindMillis();
        scheduleUnbind(true);
    }

    private void scheduleUnbind(boolean delay) {
        long unbindDelay = getTimeoutIdleBindMillis();

        if (unbindDelay <= 0) {
        if (unbindDelay <= PERMANENT_BOUND_TIMEOUT_MS) {
            if (mVerbose) Slog.v(mTag, "not scheduling unbind when value is " + unbindDelay);
            return;
        }

        if (!delay) {
            unbindDelay = 0;
        }

        cancelScheduledUnbind();
        // TODO(b/117779333): make sure it's unbound if the service settings changing (right now
        // it's not)
@@ -462,9 +470,16 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I

        @Override
        public void onServiceDisconnected(ComponentName name) {
            if (mVerbose) Slog.v(mTag, "onServiceDisconnected()");
            mBinding = true;
            mService = null;
        }

        @Override
        public void onBindingDied(ComponentName name) {
            if (mVerbose) Slog.v(mTag, "onBindingDied()");
            scheduleUnbind(false);
        }
    }

    private boolean checkIfDestroyed() {