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

Commit 594f0925 authored by Debashish Chatterjee's avatar Debashish Chatterjee
Browse files

Clear missed call notification.

The current implementation failed to clear missed call notification
because it requires the parent activity's window to in focus.

Due to some reasons getActivity().hasWindowFocus() returns false when
invoked from onResume(). By experimenting it came up that the window
gets focus AFTER the fragment is resumed.

The fix is to to use KeygaurdManager.inKeyguardRestrictedInputMode() to
determine if the keygaurd is on, and not remove the notification if so.

Bug: 4521535

Change-Id: I56cf82d708d7c694a966bdd6b79a328895c86048
parent b7a508f9
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.ITelephony;
import com.google.common.annotations.VisibleForTesting;

import android.app.KeyguardManager;
import android.app.ListFragment;
import android.content.ContentUris;
import android.content.Context;
@@ -171,6 +172,7 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
    private View mStatusMessageView;
    private TextView mStatusMessageText;
    private TextView mStatusMessageAction;
    private KeyguardManager mKeyguardManager;

    public static final class ContactInfo {
        public long personId = -1;
@@ -857,6 +859,8 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
        mVoiceMailNumber = ((TelephonyManager) getActivity().getSystemService(
                Context.TELEPHONY_SERVICE)).getVoiceMailNumber();
        mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(), this);
        mKeyguardManager =
                (KeyguardManager) getActivity().getSystemService(Context.KEYGUARD_SERVICE);
        setHasOptionsMenu(true);
    }

@@ -960,11 +964,6 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
    public void onStop() {
        super.onStop();
        resetNewCallsFlag();
        // Clear notifications only when window gains focus.  This activity won't
        // immediately receive focus if the keyguard screen is above it.
        if (getActivity().hasWindowFocus()) {
            removeMissedCallNotifications();
        }
    }

    @Override
@@ -1158,9 +1157,9 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
        startCallsQuery();
        startVoicemailStatusQuery();
        mAdapter.mPreDrawListener = null; // Let it restart the thread after next draw
        // Clear notifications only when window gains focus.  This activity won't
        // immediately receive focus if the keyguard screen is above it.
        if (getActivity().hasWindowFocus()) {
        // We don't want to remove notification when keyguard is on because the user has likely not
        // seen the new call yet.
        if (!mKeyguardManager.inKeyguardRestrictedInputMode()) {
            removeMissedCallNotifications();
        }
    }