summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
author Nate Myren <ntmyren@google.com> 2024-12-19 15:42:02 -0800
committer Nate Myren <ntmyren@google.com> 2024-12-30 11:58:59 -0800
commit91adae30e12397c3f55c4c7e4e251da344f2e086 (patch)
treeb27c0c98a55cf951279cc75876e165a9f3b1ea69 /service
parent2bd68623fd928b42cc7af6f7815b0b69ab965d1d (diff)
Block accessibility service enabling while in a call
This also adds a "reason" to the ecm dialog, to be used in determining which version of the dialog to show Bug: 364535720 Test: manual Flag: android.permission.flags.enhanced_confirmation_in_call_apis_enabled Relnote: 25Q2 feature work Change-Id: I4be7e63d616d80ac196e88524b2f4cbda2d0c405
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/ecm/EnhancedConfirmationService.java33
1 files changed, 23 insertions, 10 deletions
diff --git a/service/java/com/android/ecm/EnhancedConfirmationService.java b/service/java/com/android/ecm/EnhancedConfirmationService.java
index 65fde6daf..dde5404a4 100644
--- a/service/java/com/android/ecm/EnhancedConfirmationService.java
+++ b/service/java/com/android/ecm/EnhancedConfirmationService.java
@@ -16,6 +16,9 @@
package com.android.ecm;
+import static android.app.ecm.EnhancedConfirmationManager.REASON_APP_OP_RESTRICTED;
+import static android.app.ecm.EnhancedConfirmationManager.REASON_PHONE_STATE;
+
import android.Manifest;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
@@ -89,7 +92,7 @@ public class EnhancedConfirmationService extends SystemService {
private static final int CALL_TYPE_UNTRUSTED = 0;
private static final int CALL_TYPE_TRUSTED = 1;
- private static final int CALL_TYPE_EMERGENCY = 2;
+ private static final int CALL_TYPE_EMERGENCY = 1 << 1;
@IntDef(flag = true, value = {
CALL_TYPE_UNTRUSTED,
CALL_TYPE_TRUSTED,
@@ -269,6 +272,8 @@ public class EnhancedConfirmationService extends SystemService {
PROTECTED_SETTINGS.add(AppOpsManager.OPSTR_REQUEST_INSTALL_PACKAGES);
UNTRUSTED_CALL_RESTRICTED_SETTINGS.add(
AppOpsManager.OPSTR_REQUEST_INSTALL_PACKAGES);
+ UNTRUSTED_CALL_RESTRICTED_SETTINGS.add(
+ AppOpsManager.OPSTR_BIND_ACCESSIBILITY_SERVICE);
}
}
@@ -287,10 +292,16 @@ public class EnhancedConfirmationService extends SystemService {
public boolean isRestricted(@NonNull String packageName, @NonNull String settingIdentifier,
@UserIdInt int userId) {
+ return getRestrictionReason(packageName, settingIdentifier, userId) != null;
+ }
+
+ public String getRestrictionReason(@NonNull String packageName,
+ @NonNull String settingIdentifier,
+ @UserIdInt int userId) {
enforcePermissions("isRestricted", userId);
if (!UserUtils.isUserExistent(userId, getContext())) {
Log.e(LOG_TAG, "user " + userId + " does not exist");
- return false;
+ return null;
}
Preconditions.checkStringNotEmpty(packageName, "packageName cannot be null or empty");
@@ -299,12 +310,13 @@ public class EnhancedConfirmationService extends SystemService {
try {
if (!isSettingEcmProtected(settingIdentifier)) {
- return false;
+ return null;
}
- if (isSettingProtectedGlobally(settingIdentifier)) {
- return true;
+ String globalProtectionReason = getGlobalProtectionReason(settingIdentifier);
+ if (globalProtectionReason != null) {
+ return globalProtectionReason;
}
- return isPackageEcmGuarded(packageName, userId);
+ return isPackageEcmGuarded(packageName, userId) ? REASON_APP_OP_RESTRICTED : null;
} catch (NameNotFoundException e) {
throw new IllegalArgumentException(e);
}
@@ -513,12 +525,13 @@ public class EnhancedConfirmationService extends SystemService {
return false;
}
- private boolean isSettingProtectedGlobally(@NonNull String settingIdentifier) {
- if (UNTRUSTED_CALL_RESTRICTED_SETTINGS.contains(settingIdentifier)) {
- return isUntrustedCallOngoing();
+ private String getGlobalProtectionReason(@NonNull String settingIdentifier) {
+ if (UNTRUSTED_CALL_RESTRICTED_SETTINGS.contains(settingIdentifier)
+ && isUntrustedCallOngoing()) {
+ return REASON_PHONE_STATE;
}
- return false;
+ return null;
}
@Nullable