Skip to main content

Offline Camera Instrumentation

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.

warning
  • Instrumentation must be performed before obfuscation.
  • Performing instrumentation on an already obfuscated application is not supported.
  • Applications that are obfuscated are not supported for manual or offline instrumentation.
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 Digital.ai Testing libraries, make these changes to the source code.

note

Supported Android version 7 and above

  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>