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

Commit bc093c37 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Handle onBindingDied in AbstractRemoteService

If the package is "pm clear"-ed the binding dies permanently and has to
be re-created. Hence force an unbind at this time.

Test: atest CtsPermissionTestCases:android.permission.cts.LocationAccessCheckTest#notificationIsShownAgainAfterUninstallAndReinstall
Bug: 129480112
Change-Id: I3f9b106e2f172f8d5b6510a07c4b1f060de192bd
parent 44519220
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() {