Android take photo on unlock secretly -


i trying build app captures photo everytime phone unlocked. user should not see photo has been taken. should behave anti-theft app.

i have read should use dummy surfacetexture, preview not shown on screen, not able capture photo.

here have written far. sample activity in touch camera object:

package com.brushmate.chameleon;  import java.io.ioexception;  import android.graphics.surfacetexture; import android.hardware.camera; import android.os.bundle; import android.os.systemclock; import android.annotation.suppresslint; import android.app.activity; import android.util.log; import android.view.surfaceview;  public class settingsactivity extends activity {     private static final string tag = "chameleon wallpaper";      @suppresslint("newapi") protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_settings);          log.d(tag, "activity created");          camera cam = getcamera();          if (cam != null) {             log.d(tag, "camera available");              surfacetexture dummy = new surfacetexture(0);              try {             cam.setpreviewtexture(dummy);             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }              log.d(tag, "preview texture set");              cam.startpreview();              log.d(tag, "preview started");              cam.takepicture(null, null, new camera.picturecallback() {                  @override                 public void onpicturetaken(byte[] data, camera camera) {                     log.d(tag, "image taken");                 }             });              cam.stoppreview();              log.d(tag, "preview stopped");              cam.release();              log.d(tag, "camera released");         }     }      private camera getcamera() {         camera cam = null;          try {             cam = camera.open();         } catch (runtimeexception e) {             log.e(tag, "camera not available", e);         }          return cam;     }  } 

and here logcat output:

05-12 23:54:56.947: d/chameleon wallpaper(19614): activity created 05-12 23:54:56.947: i/awesomeplayer(161): setdatasource_l(url suppressed) 05-12 23:54:56.977: i/awesomeplayer(161): setdatasource_l(url suppressed) 05-12 23:54:57.007: i/cameraclient(161): opening camera 0 05-12 23:54:57.117: e/mm-camera(175): sensor_load_chromatix: libchromatix_imx111_preview.so: 30 05-12 23:54:57.217: e/mm-camera(175): vfe_ops_init: e 05-12 23:54:57.237: e/mm-camera(175): vfe_legacy_stats_buffer_init: aec_stats_bufnum 05-12 23:54:57.237: e/mm-camera(175): vfe_legacy_stats_buffer_init: aec_stats_bufnum 05-12 23:54:57.247: e/mm-camera(175): mctl_init_stats_proc_info: snap_max_line_cnt =30096 05-12 23:54:57.267: d/chameleon wallpaper(19614): camera available 05-12 23:54:57.267: d/chameleon wallpaper(19614): preview texture set 05-12 23:54:57.267: e/qcamerahwi(161): android::status_t android::qcamerahardwareinterface::setpreviewwindow(preview_stream_ops_t*): mpreviewwindow = 0x0x400b9e98, mstreamdisplay = 0x0x4008c378 05-12 23:54:57.267: d/qcamerahwi(161): android::status_t android::qcamerahardwareinterface::startpreview():  start preview 05-12 23:54:57.267: i/qcamerahwi(161): android::status_t android::qcamerahardwareinterface::startpreview2():setting zsl mode 05-12 23:54:57.267: e/mm-camera(175): config_proc_camera_set_inform_startpreview 05-12 23:54:57.267: e/mm-camera(175): config_update_stream_info storing stream parameters video inst 1 : width = 640, height 480, format = 1 inst_handle = 810081 cid = 0 05-12 23:54:57.307: e/mm-camera(175): config_update_stream_info storing stream parameters video inst 3 : width = 640, height 480, format = 1 inst_handle = 830083 cid = 0 05-12 23:54:57.307: e/mm-camera(175): config_update_stream_info storing stream parameters video inst 4 : width = 512, height 384, format = 1 inst_handle = 840084 cid = 0 05-12 23:54:57.307: e/mm-camera(175): config_decide_vfe_outputs: ports used 3, op mode 1 05-12 23:54:57.307: e/mm-camera(175): config_decide_vfe_outputs current mode 0 full size streaming : disabled 05-12 23:54:57.307: e/mm-camera(175): config_decide_vfe_outputs: primary: 640x480, extra_pad: 0x0, fmt: 1, type: 1, path: 1 05-12 23:54:57.307: e/mm-camera(175): config_decide_vfe_outputs: secondary: 640x480, extra_pad: 0x0, fmt: 1, type: 3, path: 4 05-12 23:54:57.307: e/mm-camera(175): config_update_inst_handles updated inst handles 810081, 830083, 0, 0  05-12 23:54:57.387: w/activitymanager(592): activity pause timeout activityrecord{420bd848 u0 com.brushmate.chameleon/.settingsactivity} 05-12 23:54:57.447: e/mm-camera(175): sensor_load_chromatix: libchromatix_imx111_zsl.so: 26 05-12 23:54:57.537: e/mm-camera(175): camif_client_set_params: camif has associated obj mask 0x1 05-12 23:54:57.537: e/mm-camera(175): config_v2_camera_start_common camif_params_add_obj_id failed -1  05-12 23:54:57.537: e/mm-camera(175): vfe_operation_config: format 3 05-12 23:54:57.537: e/mm-camera(175): vfe_operation_config:vfe_op_mode=5 05-12 23:54:57.537: e/mm-camera(175): invalid asd set params type 05-12 23:54:57.537: e/mm-camera(175): vfe_set_bestshot: bestshot mode not changed 05-12 23:54:57.567: d/chameleon wallpaper(19614): preview started 05-12 23:54:57.607: e/mm-libcamera2(161): profile hal: first preview frame received: 1368395697.614272749 05-12 23:54:57.607: e/bufferqueue(19614): [unnamed-19614-0] dequeuebuffer: min undequeued buffer count (2) exceeded (dequeued=6 undequeudcount=0) 05-12 23:54:57.647: e/mm-libcamera2(161): mm_camera_dispatch_buffered_frames: mframe 0x0, sframe = 0x0 05-12 23:54:57.647: e/mm-libcamera2(161): profile hal: stoppreview(): e: 1368395697.653949232 05-12 23:54:57.647: e/mm-camera(175): config_msg_id_stop_ack: streamon_mask not clear. should not call pp_release_hw 05-12 23:54:57.667: d/chameleon wallpaper(19614): preview stopped 05-12 23:54:57.667: e/mm-libcamera2(161): profile hal: stoppreview(): e: 1368395697.676839512 05-12 23:54:57.667: e/qcamerahwi(161): android::status_t android::qcamerahardwareinterface::setpreviewwindow(preview_stream_ops_t*):received setting null preview window 05-12 23:54:57.677: e/qcamerahwi(161): android::status_t android::qcamerahardwareinterface::setpreviewwindow(preview_stream_ops_t*): mpreviewwindow = 0x0x0, mstreamdisplay = 0x0x4008c378 05-12 23:54:57.677: w/qcamerahwi_preview(161):  setting null preview window  05-12 23:54:57.677: i/cameraclient(161): destroying camera 0 05-12 23:54:57.687: e/mm-camera(175): config_shutdown_pp camera not in streaming mode. returning.  05-12 23:54:57.687: e/mm-camera(175): vfe_ops_deinit: e 05-12 23:54:57.758: d/chameleon wallpaper(19614): camera released 05-12 23:54:57.758: w/audioflinger(161): session id 77 not found pid 161 05-12 23:54:57.758: w/audioflinger(161): session id 78 not found pid 161 05-12 23:54:57.808: d/libegl(19614): loaded /system/lib/egl/libegl_adreno200.so 05-12 23:54:57.808: d/libegl(19614): loaded /system/lib/egl/libglesv1_cm_adreno200.so 05-12 23:54:57.808: d/libegl(19614): loaded /system/lib/egl/libglesv2_adreno200.so 05-12 23:54:57.818: i/adreno200-egl(19614): <eglinitialize:269>: egl 1.4 qualcomm build: nondeterministic au_full_mako_partner-android/jb-mr1-dev_cl2961380_release_au (cl2961380) 05-12 23:54:57.818: i/adreno200-egl(19614): build date: 12/10/12 mon 05-12 23:54:57.818: i/adreno200-egl(19614): local branch:  05-12 23:54:57.818: i/adreno200-egl(19614): remote branch: m/partner-android/jb-mr1-dev 05-12 23:54:57.818: i/adreno200-egl(19614): local patches: none 05-12 23:54:57.818: i/adreno200-egl(19614): reconstruct branch: nothing 05-12 23:54:57.848: d/openglrenderer(19614): enabling debug mode 0 05-12 23:54:57.888: i/activitymanager(592): displayed com.brushmate.chameleon/.settingsactivity: +1s63ms 

as far understood, procedure correct. doing wrong?

after days of trying , further reading found out timing problem. camera object released before jpeg callback called. have release camera inside callback.

package com.brushmate.chameleon;  import java.io.ioexception;  import android.graphics.surfacetexture; import android.hardware.camera; import android.os.bundle; import android.os.systemclock; import android.annotation.suppresslint; import android.app.activity; import android.util.log; import android.view.surfaceview;  public class settingsactivity extends activity {     private static final string tag = "chameleon wallpaper";      @suppresslint("newapi") protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_settings);          log.d(tag, "activity created");          camera cam = getcamera();          if (cam != null) {             log.d(tag, "camera available");              surfacetexture dummy = new surfacetexture(0);              try {             cam.setpreviewtexture(dummy);             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }              log.d(tag, "preview texture set");              cam.startpreview();              log.d(tag, "preview started");              cam.takepicture(null, null, new camera.picturecallback() {                  @override                 public void onpicturetaken(byte[] data, camera camera) {                     log.d(tag, "image taken");                      cam.stoppreview();                      log.d(tag, "preview stopped");                      cam.release();                      log.d(tag, "camera released");                 }             });         }     }      private camera getcamera() {         camera cam = null;          try {             cam = camera.open();         } catch (runtimeexception e) {             log.e(tag, "camera not available", e);         }          return cam;     }  } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -