diff options
-rw-r--r-- | java/com/android/dialer/main/impl/OldMainActivityPeer.java | 14 | ||||
-rw-r--r-- | java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java | 9 |
2 files changed, 13 insertions, 10 deletions
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 9ac351094..e3d42fa9e 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -457,6 +457,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return DialpadFragment.isAddCallMode(intent); } + @SuppressLint("MissingPermission") @Override public void onActivityResume() { callLogFragmentListener.onActivityResume(); @@ -492,11 +493,16 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen bottomNavTabListener.ensureCorrectCallLogShown(); bottomNavTabListener.ensureCorrectVoicemailShown(); + // Config the badge of missed calls for the new call log. if (bottomNavTabListener.newCallLogFragmentActive()) { - missedCallCountObserver.onChange(false); // Set the initial value for the badge - activity - .getContentResolver() - .registerContentObserver(Calls.CONTENT_URI, true, missedCallCountObserver); + if (PermissionsUtil.hasCallLogReadPermissions(activity)) { + missedCallCountObserver.onChange(false); // Set the initial value for the badge + activity + .getContentResolver() + .registerContentObserver(Calls.CONTENT_URI, true, missedCallCountObserver); + } else { + bottomNav.setNotificationCount(TabIndex.CALL_LOG, 0); + } } // add 1 sec delay to get memory snapshot so that dialer wont react slowly on resume. diff --git a/java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java b/java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java index ee7f6d006..a4995c1e6 100644 --- a/java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java +++ b/java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java @@ -16,15 +16,15 @@ package com.android.dialer.main.impl.bottomnav; -import android.annotation.SuppressLint; +import android.Manifest; import android.content.Context; import android.database.ContentObserver; import android.database.Cursor; import android.provider.CallLog.Calls; +import android.support.annotation.RequiresPermission; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.UiListener; import com.android.dialer.main.impl.bottomnav.BottomNavBar.TabIndex; -import com.android.dialer.util.PermissionsUtil; import com.google.common.util.concurrent.ListenableFuture; /** @@ -45,7 +45,7 @@ public final class MissedCallCountObserver extends ContentObserver { this.uiListener = uiListener; } - @SuppressLint("MissingPermission") + @RequiresPermission(Manifest.permission.READ_CALL_LOG) @Override public void onChange(boolean selfChange) { ListenableFuture<Integer> countFuture = @@ -53,9 +53,6 @@ public final class MissedCallCountObserver extends ContentObserver { .backgroundExecutor() .submit( () -> { - if (!PermissionsUtil.hasCallLogReadPermissions(appContext)) { - return 0; - } try (Cursor cursor = appContext .getContentResolver() |