From 90297d3e9814645f3aff4dd365b523695e26448f Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 1 Feb 2018 11:22:10 -0800 Subject: Handle missing contact permission for preferred SIM Bug: 72163953,72749906 Test: Unit tests PiperOrigin-RevId: 184167756 Change-Id: I19f4a71fb443fbb31960be486c3c5e996535fc32 --- java/com/android/dialer/precall/impl/CallingAccountSelector.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java index d5ee0f278..e92832947 100644 --- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java +++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java @@ -62,6 +62,7 @@ import com.android.dialer.preferredsim.PreferredSimFallbackContract.PreferredSim import com.android.dialer.preferredsim.suggestion.SimSuggestionComponent; import com.android.dialer.preferredsim.suggestion.SuggestionProvider.Suggestion; import com.android.dialer.telecom.TelecomUtil; +import com.android.dialer.util.PermissionsUtil; import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import java.util.ArrayList; @@ -311,6 +312,12 @@ public class CallingAccountSelector implements PreCallAction { if (!isPreferredSimEnabled(context)) { return result; } + if (!PermissionsUtil.hasContactsReadPermissions(context)) { + LogUtil.i( + "CallingAccountSelector.PreferredAccountWorker.doInBackground", + "missing READ_CONTACTS permission"); + return result; + } result.dataId = getDataId(context, phoneNumber); if (result.dataId.isPresent()) { result.phoneAccountHandle = getPreferredAccount(context, result.dataId.get()); -- cgit v1.2.3