Skip to main content

Offline Camera Instrumentation

info

Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .

Offline Camera Instrumentation is the process of adding camera mocking capabilities to the app in the app build process, as opposed to adding those libraries in the import process.

info

This feature is not supported for apps which delegate camera actions to third party libraries.

info

To obtain the source code JAR, contact technical support.

Instrumenting Camera 1 Libraries

To work with the camera 1 Continuous Testing libraries, make these changes to the source code.

  1. Add the Jar mock-camera1 to your app's build.gradle.

  2. Replace all occurrences of android.hardware.camera with com.mock.Camera.

  3. Add the following tag to manifest.

    <receiver android:name="com.mock.ImR" android:enabled="true" android:exported="true" >

       <intent-filter>

           <action android:name= "<your app package id>.mcip.ir"/>

       </intent-filter>

    </receiver>

Instrumenting Camera 2 Libraries

  1. Add the JAR mock-camera2 to your app's build.gradle.

  2. Replace all these:

    • Class android.hardware.camera2.CameraManage" with com.mock.CameraManager.
    • getSystemService(Context.*CAMERA_SERVICE*) with CameraManagerInstantiator.*get*(this)
    • Class android.view.TextureView with com.mock.TextureView
    • Class android.media.ImageReader with com.mock.ImageReader
  3. In the res files, replace occurrences of TextureView with com.mock.TextureView.

  4. Add the following tag to manifest:

    <receiver android:name="com.mock.CameraReceiver" android:enabled="true" android:exported="true" >

       <intent-filter>

           <action android:name= "<your app package id>.mcip2.ir"/>

       </intent-filter>

    </receiver>