From 0645e07016ceccda0866d685ad3d50ad785f0904 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Tue, 15 Mar 2022 12:02:53 -0700 Subject: [PATCH] Restrict PHONE_CALL ops based on TelecomService PHONE_CALL ops should be restricted here under the conditions of the TelecomService not being started. Bug: 224603811 Test: manual, atest AppOpsTest#ensurePhoneCallOpsRestricted Change-Id: I7cdec39aebecc6e262791aa75b33afbac8513af7 --- .../core/java/com/android/server/policy/AppOpsPolicy.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/policy/AppOpsPolicy.java b/services/core/java/com/android/server/policy/AppOpsPolicy.java index 70d69c6635721..e157a277366f5 100644 --- a/services/core/java/com/android/server/policy/AppOpsPolicy.java +++ b/services/core/java/com/android/server/policy/AppOpsPolicy.java @@ -187,8 +187,12 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat initializeActivityRecognizersTags(); - // If this device does not have telephony, restrict the phone call ops - if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { + // Restrict phone call ops if the TelecomService will not start (conditioned on having + // FEATURE_MICROPHONE, FEATURE_TELECOM, or FEATURE_TELEPHONY). + PackageManager pm = mContext.getPackageManager(); + if (!pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) + && !pm.hasSystemFeature(PackageManager.FEATURE_MICROPHONE) + && !pm.hasSystemFeature(PackageManager.FEATURE_TELECOM)) { AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class); appOps.setUserRestrictionForUser(AppOpsManager.OP_PHONE_CALL_MICROPHONE, true, mToken, null, UserHandle.USER_ALL);