summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-04-27 09:58:00 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-28 22:25:06 -0700
commitea1acce9b02cc6cf305c75cad733939527c7775b (patch)
tree44c748c4b15f407b3083be1d9f2f6757308759c6
parentc28ed7444c25d52fd3996f8edf076a1d740d4e05 (diff)
Handle missing permission.READ_CALL_LOG when initializing the badge for missed calls.
Bug: 78458610 Test: MainActivityOldPeerTest PiperOrigin-RevId: 194555035 Change-Id: Ib3ef02ec3f4a8ce7cfce6d052fce3b9b6daf75e5
-rw-r--r--java/com/android/dialer/main/impl/OldMainActivityPeer.java14
-rw-r--r--java/com/android/dialer/main/impl/bottomnav/MissedCallCountObserver.java9
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()