31

While using camera in service mobile screen is getting un-touchable(locked by transparent window ) and only below error is occuring

Access denied finding property "camera.hal1.packagelist"

what will be the reason and its solution? Please help..

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Amin Pinjari
  • 2,129
  • 3
  • 25
  • 53

6 Answers6

4

I was working with the OpenCV tutorial code for camera app on android. I encountered the same error, and after looking at the answers I indeed missed one permission.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Although the app doesn't save any data externally, without this permission, the access denied error occurs. Hope it helps.

  • what is the reason for this ? – Bineesh P Babu Mar 30 '19 at 05:44
  • Found another helpful link which suggested to actually check App permissions in settings . In my case, permissions got revoked : https://stackoverflow.com/questions/37889800/cannot-open-camera-an-error-occurred-while-connecting-to-camera-0 – Shrey Aug 30 '19 at 07:24
2

I got the same error in my app, i was using surface view and had it weight set to zero. I changed it back to 1 and the error got resolved. Do check your xml code, it may help.

1

I had the same problem with the Camera 1 API on my Test device "LG V30". I found out, that this message (Access denied finding property "camera.hal1.packagelist") appeared when I opened the camera like this:

int numberOfCameras = Camera.getNumberOfCameras();
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < numberOfCameras; i++) {
    Camera.getCameraInfo(i, cameraInfo);
    if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
        camera = Camera.open(i);
        cameraId = i;
    }
}

Important is, that this only happened for the LG V30, which has 2 back cameras (numberOfCameras=3).

After some testing I found out, that this works for this device:

/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
    Camera c = null;
    try {
        c = Camera.open(); // attempt to get a Camera instance
    }
    catch (Exception e){
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}

The example code above will access the first, back-facing camera on a device with more than one camera. Here you can find a detailed description.

Manuel Schmitzberger
  • 5,162
  • 3
  • 36
  • 45
0

Please see if you asking for the Camera permission from the user. Just specifying the permission in manifest is not gonna work above a certain Android level.
This will solve your problem.

How to ask for permission follow this link.

akkilis
  • 1,904
  • 14
  • 21
  • I have asked required permissions, that is not an issue – Amin Pinjari May 10 '18 at 04:17
  • Strange I was getting the exact same issue you described when I was using my app on Android Oreo device. As soon as I started asking permission it got resolved. Also the error logs also says the same. – akkilis May 10 '18 at 08:08
  • may be your issue had permissions issue, but in this case, permissions are being asked, and I am not even testing on Oreo, I am testing on One Plus3, 5 devices – Amin Pinjari May 10 '18 at 08:58
0

about Access denied finding property like error

  • less possible reason: lack related user permission
    • which
      • should added related config
        • <uses-permission android:name="android.permission.xxx"/>
      • when running app, first popup window for grant related permission, user self should Accept it
        • to give/grant the permission to app
  • most possible reason = probably:
    • cause by (previous log, you can see it logcat) the warning log:
      • type=1400 audit(xxx): avc: denied { xxx } for name=xxx dev=xxx ino=xxx scontext=xxx tcontext=xxx tclass=xxx permissive=0

how to fix avc: denied error ?

crifan
  • 12,947
  • 1
  • 71
  • 56
0

My problem was for using Camera in android versions higher than API 23, I made two implementations.

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        camera = Camera.open();
        parameters = camera.getParameters();
        camera.startPreview();
    }

...

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            cameraManager.setTorchMode(cameraId, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
        camera.setParameters(parameters);
    }

For more information there is Camera, Camera2 and CameraX source https://developer.android.com/training/camera/choose-camera-library

Wilmer
  • 482
  • 8
  • 11