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

Commit 9f2c15bf authored by Alex Salo's avatar Alex Salo Committed by Automerger Merge Worker
Browse files

Merge "Fail early in RotationResolverService if camera lock is enabled" into sc-dev am: 81a6b27e

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

Change-Id: I4b98be6d06a259a0342c6863074dfb5ed6f824ba
parents d13936ca 81a6b27e
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.Manifest;
import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.content.Context;
import android.hardware.SensorPrivacyManager;
import android.os.Binder;
import android.os.CancellationSignal;
import android.os.ResultReceiver;
@@ -79,6 +80,7 @@ public class RotationResolverManagerService extends
            FrameworkStatsLog.AUTO_ROTATE_REPORTED__PROPOSED_ORIENTATION__FAILURE;

    private final Context mContext;
    private final SensorPrivacyManager mPrivacyManager;
    boolean mIsServiceEnabled;

    public RotationResolverManagerService(Context context) {
@@ -89,6 +91,7 @@ public class RotationResolverManagerService extends
                PACKAGE_UPDATE_POLICY_REFRESH_EAGER
                        | /*To avoid high rotation latency*/ PACKAGE_RESTART_POLICY_REFRESH_EAGER);
        mContext = context;
        mPrivacyManager = SensorPrivacyManager.getInstance(context);
    }

    @Override
@@ -156,15 +159,22 @@ public class RotationResolverManagerService extends
            Objects.requireNonNull(callbackInternal);
            Objects.requireNonNull(cancellationSignalInternal);
            synchronized (mLock) {
                if (mIsServiceEnabled) {
                    final RotationResolverManagerPerUserService service = getServiceForUserLocked(
                final boolean isCameraAvailable = !mPrivacyManager.isSensorPrivacyEnabled(
                        SensorPrivacyManager.Sensors.CAMERA);
                if (mIsServiceEnabled && isCameraAvailable) {
                    final RotationResolverManagerPerUserService service =
                            getServiceForUserLocked(
                                    UserHandle.getCallingUserId());
                    final RotationResolutionRequest request = new RotationResolutionRequest("",
                            currentRotation, proposedRotation, true, timeout);
                    service.resolveRotationLocked(callbackInternal, request,
                            cancellationSignalInternal);
                } else {
                    if (isCameraAvailable) {
                        Slog.w(TAG, "Rotation Resolver service is disabled.");
                    } else {
                        Slog.w(TAG, "Camera is locked by a toggle.");
                    }
                    callbackInternal.onFailure(ROTATION_RESULT_FAILURE_CANCELLED);
                    logRotationStats(proposedRotation, currentRotation, RESOLUTION_DISABLED);
                }