@Override public void onReceive(Context context, Intent intent) { if (wakeLock == null) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, TAG); } if (!wakeLock.isHeld()) { wakeLock.acquire(); } readyToTakePicture = true; try { if (ApplicationScreen.instance == null || ApplicationScreen.getCameraController() == null || (CameraController.getCamera() == null && CameraController.getCamera2() == null)) { Intent dialogIntent = new Intent(context, MainScreen.class); dialogIntent.addFlags( Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(dialogIntent); if (wakeLock != null) if (wakeLock.isHeld()) wakeLock.release(); } else { takePicture(); } } catch (NullPointerException e) { } }
/** The Surface is created/init() */ @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { Log.i("Almalence", "GLLayer.onSurfaceCreated()"); PluginManager.getInstance().onGLSurfaceCreated(gl, config); if (PluginManager.getInstance().shouldPreviewToGPU()) { final int[] tex = new int[1]; GLES20.glGenTextures(1, tex, 0); this.texture_preview = tex[0]; GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, this.texture_preview); GLES20.glTexParameteri( GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri( GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri( GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri( GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); this.surfaceTexture = new SurfaceTexture(this.texture_preview); this.surfaceTexture.setOnFrameAvailableListener( new OnFrameAvailableListener() { @Override public void onFrameAvailable(final SurfaceTexture surfaceTexture) { PluginManager.getInstance().onFrameAvailable(); } }); final Camera camera = CameraController.getCamera(); if (camera == null) { return; } try { camera.setDisplayOrientation(90); } catch (RuntimeException e) { e.printStackTrace(); } try { camera.setPreviewTexture(this.surfaceTexture); } catch (final IOException e) { e.printStackTrace(); } camera.startPreview(); } }
// Used only in old camera interface (HALv3 don't use it) public void setCameraPictureSize() { Camera camera = CameraController.getCamera(); if (null == camera) return; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext()); int jpegQuality = Integer.parseInt(prefs.getString(MainScreen.sJPEGQualityPref, "95")); Camera.Parameters cp = CameraController.getInstance().getCameraParameters(); cp.setPictureSize(MainScreen.getImageWidth(), MainScreen.getImageHeight()); cp.setJpegQuality(jpegQuality); try { CameraController.getInstance().setCameraParameters(cp); } catch (RuntimeException e) { Log.e("CameraTest", "MainScreen.setupCamera unable setParameters " + e.getMessage()); } }