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

Commit cb677dd8 authored by Robert Benea's avatar Robert Benea Committed by Jainam Shah
Browse files

Don't rebind deleted user, instead unbind all user services.

The problem is that onUserRemove we rebindService to the gone
uid that as a side effect would disable the bindings of the
current ACTIVE user(s).
This happens only if the user that we switch from is a GUEST
since GUEST users are ephemeral and will be removed onSwitch.

Test: manual
Fixes: 245254232

Change-Id: I442db90ebf8fc7b0a4bdc7d7e3236b076a6ddeb6
parent f619577c
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -1021,7 +1021,7 @@ abstract public class ManagedServices {
        synchronized (mSnoozing) {
            mSnoozing.remove(user);
        }
        rebindServices(true, user);
        unbindUserServices(user);
    }

    public void onUserSwitched(int user) {
@@ -1408,12 +1408,24 @@ abstract public class ManagedServices {
    void unbindOtherUserServices(int currentUser) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog();
        t.traceBegin("ManagedServices.unbindOtherUserServices_current" + currentUser);
        final SparseArray<Set<ComponentName>> componentsToUnbind = new SparseArray<>();
        unbindServicesImpl(currentUser, true /* allExceptUser */);
        t.traceEnd();
    }

    void unbindUserServices(int user) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog();
        t.traceBegin("ManagedServices.unbindUserServices" + user);
        unbindServicesImpl(user, false /* allExceptUser */);
        t.traceEnd();
    }

    void unbindServicesImpl(int user, boolean allExceptUser) {
        final SparseArray<Set<ComponentName>> componentsToUnbind = new SparseArray<>();
        synchronized (mMutex) {
            final Set<ManagedServiceInfo> removableBoundServices = getRemovableConnectedServices();
            for (ManagedServiceInfo info : removableBoundServices) {
                if (info.userid != currentUser) {
                if ((allExceptUser && (info.userid != user))
                        || (!allExceptUser && (info.userid == user))) {
                    Set<ComponentName> toUnbind =
                            componentsToUnbind.get(info.userid, new ArraySet<>());
                    toUnbind.add(info.component);
@@ -1422,7 +1434,6 @@ abstract public class ManagedServices {
            }
        }
        unbindFromServices(componentsToUnbind);
        t.traceEnd();
    }

    protected void unbindFromServices(SparseArray<Set<ComponentName>> componentsToUnbind) {