On non-telephony devices, restrict PHONE_CALL ops

Devices without telephony don't make phone calls.

Bug: 190503604
Test: manual
Change-Id: I5b84dffdf33b679940ce44bebf6ad4df626fb680
This commit is contained in:
Nate Myren
2021-06-29 12:18:43 -07:00
parent c2a780dbd6
commit 224fcc1d16

View File

@@ -32,6 +32,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.location.LocationManagerInternal;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.os.PackageTagsList;
import android.os.Process;
@@ -71,6 +72,9 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
@NonNull
private final Object mLock = new Object();
@NonNull
private final IBinder mToken = new Binder();
@NonNull
private final Context mContext;
@@ -180,6 +184,15 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
}, UserHandle.SYSTEM);
initializeActivityRecognizersTags();
// If this device does not have telephony, restrict the phone call ops
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class);
appOps.setUserRestrictionForUser(AppOpsManager.OP_PHONE_CALL_MICROPHONE, true, mToken,
null, UserHandle.USER_ALL);
appOps.setUserRestrictionForUser(AppOpsManager.OP_PHONE_CALL_CAMERA, true, mToken,
null, UserHandle.USER_ALL);
}
}
private static boolean isHotwordDetectionServiceRequired(PackageManager pm) {