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

Commit 59e3a609 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Fix issue where work profiles cause missed calls to not show after boot.

When a user with a work profile reboots their device, Telecom tracks the
user which is pending reload of the missed call notification and defers
the process until boot complete.

This is problematic as there is only one user tracked, and during boot
the work profile user ends up overwriting the primary user.

To fix this, now tracking a list of users to load after boot complete so
that the work profile and primary work profile both reload the missed
call notification, not just the work profile user.

Test: Manually reproduced bug and verified Missed Call notification now
shows up.
Bug: 73164872

Change-Id: I39c87eae9c5dcf85f9d14448dc40acb22c2dc843
parent ad4ebc02
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.internal.telephony.CallerInfo;

import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
@@ -134,7 +135,7 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
    // Used to track the number of missed calls.
    private ConcurrentMap<UserHandle, AtomicInteger> mMissedCallCounts;

    private UserHandle userToLoadAfterBootComplete;
    private List<UserHandle> mUsersToLoadAfterBootComplete = new ArrayList<>();

    public MissedCallNotifierImpl(Context context, PhoneAccountRegistrar phoneAccountRegistrar,
            DefaultDialerCache defaultDialerCache) {
@@ -271,7 +272,7 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
    }

    private void showMissedCallNotification(@NonNull CallInfo callInfo, UserHandle userHandle) {
        Log.i(this, "showMissedCallNotification()");
        Log.i(this, "showMissedCallNotification: userHandle=%d", userHandle.getIdentifier());
        mMissedCallCounts.putIfAbsent(userHandle, new AtomicInteger(0));
        int missCallCounts = mMissedCallCounts.get(userHandle).incrementAndGet();

@@ -537,10 +538,14 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
    @Override
    public void reloadAfterBootComplete(final CallerInfoLookupHelper callerInfoLookupHelper,
            CallInfoFactory callInfoFactory) {
        if (userToLoadAfterBootComplete != null) {
            reloadFromDatabase(callerInfoLookupHelper,
                    callInfoFactory, userToLoadAfterBootComplete);
            userToLoadAfterBootComplete = null;
        if (!mUsersToLoadAfterBootComplete.isEmpty()) {
            for (UserHandle handle : mUsersToLoadAfterBootComplete) {
                Log.i(this, "reloadAfterBootComplete: user=%d", handle.getIdentifier());
                reloadFromDatabase(callerInfoLookupHelper, callInfoFactory, handle);
            }
            mUsersToLoadAfterBootComplete.clear();
        } else {
            Log.i(this, "reloadAfterBootComplete: no user(s) to check; skipping reload.");
        }
    }
    /**
@@ -549,11 +554,12 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
    @Override
    public void reloadFromDatabase(final CallerInfoLookupHelper callerInfoLookupHelper,
            CallInfoFactory callInfoFactory, final UserHandle userHandle) {
        Log.d(this, "reloadFromDatabase()...");
        Log.d(this, "reloadFromDatabase: user=%d", userHandle.getIdentifier());
        if (TelecomSystem.getInstance() == null || !TelecomSystem.getInstance().isBootComplete()) {
            Log.i(this, "Boot not yet complete -- call log db may not be available. Deferring " +
                    "loading until boot complete.");
            userToLoadAfterBootComplete = userHandle;
            Log.i(this, "reloadFromDatabase: Boot not yet complete -- call log db may not be "
                    + "available. Deferring loading until boot complete for user %d",
                    userHandle.getIdentifier());
            mUsersToLoadAfterBootComplete.add(userHandle);
            return;
        }