A
A
Adik Izat2020-03-09 13:14:03
android studio
Adik Izat, 2020-03-09 13:14:03

Who can help with Camera 2 API preview connection error?

Good afternoon, forum users! I ask enlightened colleagues to help) On the screen, instead of a camera, I see a rectangle painted over in GRAY color.

Error logs:

2020-03-09 16:04:42.392 10004-10004/com.example.geocam W/ActivityThread: handleWindowVisibility: no activity for token [email protected]
2020-03-09 16:04:43.131 10004-10004/com.example.geocam W/ActivityThread: handleWindowVisibility: no activity for token [email protected]
2020-03-09 16:04:43.187 10004-10004/com.example.geocam I/CameraManagerGlobal: Connecting to camera service
2020-03-09 16:04:43.189 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.183 10004-10004/com.example.geocam W/.example.geocam: type=1400 audit(0.0:68683): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=4391 scontext=u:r:untrusted_app:s0:c162,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-03-09 16:04:43.183 10004-10004/com.example.geocam I/chatty: uid=10162(com.example.geocam) identical 5 lines
2020-03-09 16:04:43.183 10004-10004/com.example.geocam W/Binder:10004_3: type=1400 audit(0.0:68689): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=4391 scontext=u:r:untrusted_app:s0:c162,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-03-09 16:04:43.189 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.183 10004-10004/com.example.geocam W/Binder:10004_3: type=1400 audit(0.0:68690): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=4391 scontext=u:r:untrusted_app:s0:c162,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
2020-03-09 16:04:43.190 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.190 10004-10004/com.example.geocam W/CameraManagerGlobal: [soar.cts] ignore the status update of camera: 2
2020-03-09 16:04:43.190 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.190 10004-10004/com.example.geocam W/CameraManagerGlobal: [soar.cts] ignore the status update of camera: 3
2020-03-09 16:04:43.190 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.190 10004-10004/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.190 10004-10004/com.example.geocam I/geoCamLogs: Камера ID: 0
2020-03-09 16:04:43.190 10004-10019/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.190 10004-10019/com.example.geocam I/chatty: uid=10162(com.example.geocam) Binder:10004_3 identical 1 line
2020-03-09 16:04:43.191 10004-10019/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.191 10004-10019/com.example.geocam W/CameraManagerGlobal: ignore the torch status update of camera: 2
2020-03-09 16:04:43.191 10004-10004/com.example.geocam I/geoCamLogs: Камера ID: 1
2020-03-09 16:04:43.191 10004-10019/com.example.geocam E/libc: Access denied finding property "vendor.camera.aux.packagelist"
2020-03-09 16:04:43.191 10004-10019/com.example.geocam W/CameraManagerGlobal: ignore the torch status update of camera: 3


As I understand it, the error is related to the inadmissibility. I am not being given permission to some property "vendor.camera.aux.packagelist". Wow, I'm a genius! No) I'm a dumbass who does not understand why this is happening)

In the manifest, I wrote that the application uses the camera:
<uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

In the camera's activity, I set the permission check, registered immediately along with the permission check to use the memory (but I haven't started using the memory yet, I'm only testing the camera):
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED
                ||
                (ContextCompat.checkSelfPermission(CameraActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
        ) {
            requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        }

What do I attribute the problem to? Theoretically, I sin on my phone, Xiaomi Mi A2. Unfortunately I don't have any other options...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adik Izat, 2020-03-09
@JaxAdam

The answer is actually very stupid))) There is an additional permission check in the method call to open the camera. In it, in comparison, he put the wrong sign. This is:

if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                    mCameraManager.openCamera(mCameraID, mCameraCallback, null);
                }else{
                    Log.e(LOG_TAG, "Нет разрешения для запуска камеры");
                }

changed to:
if (checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
                    mCameraManager.openCamera(mCameraID, mCameraCallback, null);
                }else{
                    Log.e(LOG_TAG, "Нет разрешения для запуска камеры");
                }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question