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

Commit 5fc2db50 authored by Abel Tesfaye's avatar Abel Tesfaye Committed by Automerger Merge Worker
Browse files

Merge "Fail early in AttentionManagerService if camera lock is enabled" into sc-dev am: 4cad28d8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14020329

Change-Id: Ibeb6aff855acdc908781453810aa7ef60a57c584
parents 6a4996f9 4cad28d8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.hardware.SensorPrivacyManager;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -115,6 +116,7 @@ public class AttentionManagerService extends SystemService {
    private static String sTestAttentionServicePackage;
    private final Context mContext;
    private final PowerManager mPowerManager;
    private final SensorPrivacyManager mPrivacyManager;
    private final Object mLock;
    @GuardedBy("mLock")
    @VisibleForTesting
@@ -146,6 +148,7 @@ public class AttentionManagerService extends SystemService {
        mPowerManager = powerManager;
        mLock = lock;
        mAttentionHandler = handler;
        mPrivacyManager = SensorPrivacyManager.getInstance(context);
    }

    @Override
@@ -249,6 +252,11 @@ public class AttentionManagerService extends SystemService {
            return false;
        }

        if (mPrivacyManager.isSensorPrivacyEnabled(SensorPrivacyManager.Sensors.CAMERA)) {
            Slog.w(LOG_TAG, "Camera is locked by a toggle.");
            return false;
        }

        // don't allow attention check in screen off state
        if (!mPowerManager.isInteractive()) {
            return false;