summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/historyitemactions
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-05-21 18:17:52 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-21 18:18:30 -0700
commitfec2920572350518f9600ac1820abd76fb449a1c (patch)
treee67463f8bd281f2f196346d79d3313fe5d177d30 /java/com/android/dialer/historyitemactions
parent4950fd587f2588e7958a84c5fcd814058bd2e1a3 (diff)
Don't show "Add contact" and/or "Message" in the bottom sheet if corresponding permissions are not granted.
Bug: 80059644 Test: HistoryItemActionModulesBuilderTest, PermissionUtilTest PiperOrigin-RevId: 197494701 Change-Id: I607ebd3079fa816b447fbff08cc28c96c55e22bb
Diffstat (limited to 'java/com/android/dialer/historyitemactions')
-rw-r--r--java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
index a09f6e10b..0e78d70f5 100644
--- a/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
+++ b/java/com/android/dialer/historyitemactions/HistoryItemActionModulesBuilder.java
@@ -32,6 +32,7 @@ import com.android.dialer.duo.DuoComponent;
import com.android.dialer.logging.ReportingLocation;
import com.android.dialer.spam.Spam;
import com.android.dialer.util.CallUtil;
+import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.util.UriUtils;
import java.util.ArrayList;
import java.util.List;
@@ -179,6 +180,7 @@ public final class HistoryItemActionModulesBuilder {
* <p>The method is a no-op if
*
* <ul>
+ * <li>the permission to send SMS is not granted,
* <li>the call is one made to/received from an emergency number,
* <li>the call is one made to a voicemail box,
* <li>the number is blocked, or
@@ -188,7 +190,8 @@ public final class HistoryItemActionModulesBuilder {
public HistoryItemActionModulesBuilder addModuleForSendingTextMessage() {
// TODO(zachh): There are other conditions where this module should not be shown
// (e.g., business numbers).
- if (moduleInfo.getIsEmergencyNumber()
+ if (!PermissionsUtil.hasSendSmsPermissions(context)
+ || moduleInfo.getIsEmergencyNumber()
|| moduleInfo.getIsVoicemailCall()
|| moduleInfo.getIsBlocked()
|| TextUtils.isEmpty(moduleInfo.getNormalizedNumber())) {
@@ -220,6 +223,7 @@ public final class HistoryItemActionModulesBuilder {
* <p>The method is a no-op if
*
* <ul>
+ * <li>the permission to write contacts is not granted,
* <li>the call is one made to/received from an emergency number,
* <li>the call is one made to a voicemail box,
* <li>the call should be shown as spam,
@@ -229,7 +233,8 @@ public final class HistoryItemActionModulesBuilder {
* </ul>
*/
public HistoryItemActionModulesBuilder addModuleForAddingToContacts() {
- if (moduleInfo.getIsEmergencyNumber()
+ if (!PermissionsUtil.hasContactsWritePermissions(context)
+ || moduleInfo.getIsEmergencyNumber()
|| moduleInfo.getIsVoicemailCall()
|| Spam.shouldShowAsSpam(moduleInfo.getIsSpam(), moduleInfo.getCallType())
|| moduleInfo.getIsBlocked()