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.
- 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.
This feature is not supported for apps which delegate camera actions to third party libraries.
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.
Supported Android version 7 and above
-
Add the Jar
mock-camera1to your app'sbuild.gradle. -
Replace all occurrences of
android.hardware.camerawithcom.mock.Camera. -
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
-
Add the JAR
mock-camera2to your app'sbuild.gradle. -
Replace all these:
- Class
android.hardware.camera2.CameraManage" withcom.mock.CameraManager. getSystemService(Context.*CAMERA_SERVICE*)withCameraManagerInstantiator.*get*(this)- Class
android.view.TextureViewwithcom.mock.TextureView - Class
android.media.ImageReaderwithcom.mock.ImageReader
- Class
-
In the res files, replace occurrences of
TextureViewwithcom.mock.TextureView. -
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>