Capture Image while Device is Locked with Password

前端 未结 2 767
[愿得一人]
[愿得一人] 2021-02-02 00:30

I want to implement a functionality to capture image through front camera when someone tries to unlock my device and enter incorrect password 3 times. I checked that it is possi

相关标签:
2条回答
  • 2021-02-02 00:41

    I have tested your code and I get a proper image so I think your camera code works fine.

    You can check my code here. I copied the CameraView class from yours. The device admin part I took from https://github.com/marakana/DevicePolicyDemo The picture is taken when the first attempt fails.

    I doubt that it might be some kind of hardware issue. I am not sure if you've seen Taking picture from camera without preview.

    The second answer there mentions that faking the preview with a dummy SurfaceView does not work on all Android devices. Please see his blog. He's done the test on various phones. You could try my project and if it doesn't work on your phone. This might be the case. (The other answers might also be useful for you.)

    I tried my code on Galaxy S3 with CM10.

    Hope this helps.

    Edit1: Tested on HTC One, HTC One X, Sony Experia. Works fine.

    Edit2: Worked on Galaxy Note.

    0 讨论(0)
  • 2021-02-02 00:53

    I'm not sure this will work on other devices, but if it does it might offer some insight into whats happening.

    In the Camera.Parameters, there is a feature to save the raw bayer image directly to the SD card. This image happens before the .jpeg file is created, so if the operating system is blanking out the image, this image might not be effected.

      Camera.Parameters parameters=camera.getParameters();
      parameters.set("rawsave-mode", "1");
      parameters.set("rawfname", "/mnt/sdcard2/test5.raw");
      camera.setParameters(parameters);
    

    If this feature works on your device, you should be able to determine if the picture is being taken and wiped out or if it not being taken at all.

    If the raw image works, it is fairly easy to convert a bayer to an RGB image or grayscale image.

    The other area i'd be looking is the logcat information and compare the logs between an unlocked context of the code and a locked context of the code. If there is a security issue, it should be reflected in the logcat.

    0 讨论(0)
提交回复
热议问题