[General Questions and Answers] iii1iii:
MIUI10 "Still can't connect to camera. Try restarting" but works in 2nd space

Xiaomi K20 Pro with root.

Builtin camera app doesn't work in the first space/profile but when I switch to second space, it works. All third party camera apps like GCam and Signal work in the first space.

I've tried:

- disabling then re-enabling all camera app permissions,

- clearing the camera app cache and data, then rebooting,

- clearing dalvik cache and rebooting,

- copying all files from the second space camera profile in /data/user/10/com.android.camera to /data/data/com.android.camera

- checking all permissions for the above directories match

Some snippets from adb shell logcat

01-27 14:16:31.647 8218 8296 D CAM_Camera2DataContaine: All available camera ids: [0, 1, 20, 21, 60, 61, 62, 63, 100, 101, 120]

01-27 14:16:31.668 8218 8218 I CAM_PermissionManager: CheckCameraPermissions(), all on

01-27 14:16:31.685 8218 8296 D CAM_Camera2DataContaine: ====================================================================

01-27 14:16:31.685 8218 8296 D CAM_Camera2DataContaine: BACK: [main, aux, sat, bokeh, virtual, infrared] = [0, 20, 60, 61, 62, 100]

01-27 14:16:31.685 8218 8296 D CAM_Camera2DataContaine: FRONT: [main, aux, sat, bokeh, virtual, infrared] = [1, 101, -1, -1, -1, -1]

01-27 14:16:31.685 8218 8296 D CAM_Camera2DataContaine: ====================================================================

01-27 14:16:31.685 8218 8296 D CAM_Camera2DataContaine: X: init()

01-27 14:16:31.687 8218 8304 V CAM_CameraUtil: execCommand value=33505 cost=32

01-27 14:16:31.688 8218 8296 D CAM_Camera2DataContaine: getActualOpenCameraId: mode=a3, id=0->120

01-27 14:16:31.690 8218 8296 D CAM_Camera2OpenManager: openCamera: pendingOpenId = 120, mPendingCameraId = -1, currentMode = 163, mCurrentModule = 160, forceClose = true

01-27 14:16:31.690 8218 8296 D CAM_Camera2OpenManager: abandonOpenObservableIfExists: E

01-27 14:16:31.691 8218 8296 D CAM_Camera2OpenManager: abandonOpenObservableIfExists: start mCameraResultEmitter = DISPOSED

01-27 14:16:31.691 8218 8296 D CAM_Camera2OpenManager: abandonOpenObservableIfExists: X

01-27 14:16:31.692 8218 8355 D CAM_Camera2OpenManager: open start

01-27 14:16:31.692 8218 8296 I CAM_PermissionManager: getNeedCheckPermissionList() listSize =0

01-27 14:16:31.692 8218 8296 I CAM_PermissionManager: CheckCameraPermissions(), all on

01-27 14:16:31.693 1158 3840 I CameraService: CameraService::connect call (PID -1 "com.android.camera", camera ID 120) for HAL version default and Camera API version 2

01-27 14:16:31.693 8218 8296 D CAM_Camera2DataContaine: getActualOpenCameraId: mode=a3, id=0->120

01-27 14:16:31.693 8218 8296 D CAM_Camera2OpenManager: openCamera: pendingOpenId = 120, mPendingCameraId = 120, currentMode = 163, mCurrentModule = 163, forceClose = false

01-27 14:16:31.693 1158 3840 I Camera2ClientBase: Camera 120: Opened. Client: com.android.camera (PID 8218, UID 10076)

01-27 14:16:31.693 1158 3840 I CameraDeviceClient: CameraDeviceClient 120: Opened

01-27 14:16:31.694 1158 3840 I CameraService: Camera 120: Access for "com.android.camera" has been restricted

01-27 14:16:31.695 1158 3840 E CameraService: connectHelper: Could not initialize client from HAL.

01-27 14:16:31.695 1158 3840 I Camera3-Device: disconnectImpl: E

01-27 14:16:31.695 1158 3840 E CameraService: unregisterMonitorUid: Trying to unregister uid: 10076 which is not monitored!

01-27 14:16:31.695 1158 3840 I CameraService: disconnect: Disconnected client for camera 120 for PID 8218

01-27 14:16:31.695 2011 4110 D PopupCameraManagerService: notifyCameraStatus cameraId 120 status : 0 clientPackageName com.android.camera

01-27 14:16:31.695 1158 3840 I Camera2ClientBase: Closed Camera 120. Client was: com.android.camera (PID 8218, UID 10076)

01-27 14:16:31.695 1158 3840 I Camera3-Device: disconnectImpl: E

01-27 14:16:31.695 8218 8355 W System.err: android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:1534: Camera "120" disabled by policy

01-27 14:16:31.695 8218 8355 W System.err:	at android.hardware.camera2.CameraManager.throwAsPublicException(Unknown Source:52)

01-27 14:16:31.695 8218 8355 W System.err:	at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(Unknown Source:210)

01-27 14:16:31.695 8218 8355 W System.err:	at android.hardware.camera2.CameraManager.openCameraForUid(Unknown Source:8)

01-27 14:16:31.695 8218 8355 W System.err:	at android.hardware.camera2.CameraManager.openCamera(Unknown Source:5)

01-27 14:16:31.695 8218 8355 W System.err:	at com.android.camera.module.loader.camera2.Camera2OpenManager.onMessage(Unknown Source:384)

01-27 14:16:31.695 8218 8355 W System.err:	at com.android.camera.module.loader.camera2.Camera2OpenManager.access$000(Unknown Source:0)

01-27 14:16:31.697 8218 8355 W System.err:	at com.android.camera.module.loader.camera2.Camera2OpenManager$1.handleMessage(Unknown Source:2)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.Handler.dispatchMessage(Unknown Source:19)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.Looper.loop(Unknown Source:233)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.HandlerThread.run(Unknown Source:28)

01-27 14:16:31.697 8218 8355 W System.err: Caused by: android.os.ServiceSpecificException: connectHelper:1534: Camera "120" disabled by policy (code 6)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.Parcel.createException(Unknown Source:82)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.Parcel.readException(Unknown Source:11)

01-27 14:16:31.697 8218 8355 W System.err:	at android.os.Parcel.readException(Unknown Source:10)

01-27 14:16:31.697 8218 8355 W System.err:	at android.hardware.ICameraService$Stub$Proxy.connectDevice(Unknown Source:64)

01-27 14:16:31.697 8218 8355 W System.err:	at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(Unknown Source:64)

Even though the logs says it's disabled by policy, the phone has no managed policies, it's a standalone device.

Anyone got ideas what to check next or how to fix it?