Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5676712 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "On non-telephony devices, restrict PHONE_CALL ops" into sc-dev

parents 88a62d67 224fcc1d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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) {