Dismiss missed calls when the call log is shown.
The notification used to be dismissed by the CallLogActivity. Now that
that class is no longer used but the CallLogFragment is used instead,
add the dismissal in the fragment.
With the fragment, detecting when the code is being shown is a bit more
complex (it takes into account both onResume and onVisibilityChanged).
Bug: 4521535
Change-Id: I01af5b3ab0e1e66e9b90d93b4957c0dff9816603
diff --git a/src/com/android/contacts/activities/CallLogActivity.java b/src/com/android/contacts/activities/CallLogActivity.java
index 4ddf4d0..4f1c8d9 100644
--- a/src/com/android/contacts/activities/CallLogActivity.java
+++ b/src/com/android/contacts/activities/CallLogActivity.java
@@ -29,7 +29,6 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
-import android.util.Log;
import android.view.KeyEvent;
import android.view.ViewConfiguration;
@@ -61,28 +60,6 @@
}
@Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
-
- // Clear notifications only when window gains focus. This activity won't
- // immediately receive focus if the keyguard screen is above it.
- if (hasFocus) {
- try {
- ITelephony telephony =
- ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
- if (telephony != null) {
- telephony.cancelMissedCallsNotification();
- } else {
- Log.w(TAG, "Telephony service is null, can't call " +
- "cancelMissedCallsNotification");
- }
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to clear missed calls notification due to remote exception");
- }
- }
- }
-
- @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_CALL: {
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index fa33430..c59cbf9 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -30,6 +30,7 @@
import com.android.contacts.voicemail.VoicemailStatusHelperImpl;
import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
import com.android.internal.telephony.CallerInfo;
+import com.android.internal.telephony.ITelephony;
import com.google.common.annotations.VisibleForTesting;
import android.app.ListFragment;
@@ -43,6 +44,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.Contacts;
@@ -1065,5 +1068,26 @@
resetNewCallsFlag();
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()) {
+ removeMissedCallNotifications();
+ }
+ }
+
+ /** Removes the missed call notifications. */
+ private void removeMissedCallNotifications() {
+ try {
+ ITelephony telephony =
+ ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
+ if (telephony != null) {
+ telephony.cancelMissedCallsNotification();
+ } else {
+ Log.w(TAG, "Telephony service is null, can't call " +
+ "cancelMissedCallsNotification");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to clear missed calls notification due to remote exception");
+ }
}
}