Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.9.1S release notes + image injection #187

Merged
merged 8 commits into from
Jan 16, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/apps/images/camera2-under-libs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/modules/apps/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
** xref:apps:biometric-authentication-sdk/add-the-sdk-to-your-android-app.adoc[]
** xref:apps:biometric-authentication-sdk/add-the-sdk-to-your-ios-app.adoc[]
** xref:apps:biometric-authentication-sdk/create-biometric-authentication-script.adoc[]

* Enable image injection
** xref:apps:image-injection-sdk/add-the-sdk-to-your-android-app.adoc[]
** xref:apps:image-injection-sdk/supported-methods.adoc[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
= Add image injection SDK to your Android app
:navtitle: Add the image injeciton SDK to your Android app

Learn how to implement Kobiton’s custom SDK in your Android application to enable Image Injection.

== Prerequisites

* Android 9 or newer.
* An Android project with https://gradle.org/[Gradle] build tool.
* The application uses `camera2` library. See the xref:apps:image-injection-sdk/supported-methods.adoc[full list] of supported methods in `camera2`.
* Download the Image Injection SDK file https://kobiton.s3.amazonaws.com/downloads/camera2.aar[here]. The downloaded file name should be: `camera2.arr`.

== Integrate the SDK

Create a new folder named *libs* under `<project_folder>/app`, where `<project_folder>` is the root folder of the Android project to be altered. Copy the downloaded `camera2.arr` file into the newly created folder.

image:apps:camera2-under-libs.png[width=500,alt="The camera2 file under the libs folder"]

Under `<project_folder>/app`, edit the *build.gradle* file and add the following line under *dependencies* to allow your application to use the `.arr` file:

[source]
----
implementation fileTree(dir: 'libs', include: ['*.aar'])
----

Under `<project_folder>/app/src/main`, edit the *AndroidManifest.xml* file and add the following lines within the _application_ tag. This service is used to connect the SDK to Kobiton Server.

[source]
----
<service android:name="kobiton.hardware.camera2.ImageInjectionClient" />
----

image:apps:android-manifest-service-content.png[width=1000,alt="The new service line in android manifest"]

Within the same *AndroidManifest.xml* file as above, add the following lines within the `manifest` tag to grant the 2 permissions `INTERNET` and `ACCESS_NETWORK_STATE` for the SDK to connect to Kobiton’s Server.

[source]
----
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
----

image:apps:android-manifest-uses-permission-content.png[width=1000,alt="The new uses permission line in android manifest"]

Replace all texts in the project according to the below table to replace the stock Android library with the custom Kobiton library:

[options="header"]
|=======================
|Replace | With
|`android.hardware.camera2.CameraCaptureSession` | `kobiton.hardware.camera2.CameraCaptureSession`
|`android.hardware.camera2.CameraDevice` | `kobiton.hardware.camera2.CameraDevice`
|`android.hardware.camera2.CameraManager` | `kobiton.hardware.camera2.CameraManager`
|`android.hardware.camera2.CaptureRequest` | `kobiton.hardware.camera2.CaptureRequest`
|`android.hardware.camera2.params.SessionConfiguration` | `kobiton.hardware.camera2.params.SessionConfiguration`
|`android.media.ImageReader` | `kobiton.media.ImageReader`
|=======================

Update the CameraManager's initial method by replacing `Context.getSystemService(Context.CAMERA_SERVICE)` with `CameraManager.getInstance(context)`. For example, replace:

[source]
----
private val cameraManager: CameraManager by lazy {
val context = requireContext().applicationContext
context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
}
----

with

[source]
----
private val cameraManager: CameraManager by lazy {
CameraManager.getInstance(requireContext().applicationContext)
}
----

After all the above changes are made, package your app into an `.apk`, `.aab` or `.zip` file.

Upload and install the app package, then follow xref:manual-testing:test-your-app-camera.adoc[this guide] to start using image injection.
170 changes: 170 additions & 0 deletions docs/modules/apps/pages/image-injection-sdk/supported-methods.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
= Supported methods of image injection SDK
:navtitle: Supported methods of image injection SDK

This article list all supported methods for the custom `camera2` library for xref:apps:image-injection-sdk/add-the-sdk-to-your-android-app.adoc[image injection].

== Supported methods

* CameraManager

** getCameraIdList()

** registerAvailabilityCallback(AvailabilityCallback callback, Handler handler)

** registerAvailabilityCallback(Executor executor, AvailabilityCallback callback)

** unregisterAvailabilityCallback(AvailabilityCallback callback)

** registerTorchCallback(TorchCallback callback, Handler handler)

** registerTorchCallback(Executor executor, TorchCallback callback)

** unregisterTorchCallback(TorchCallback callback)

** getCameraCharacteristics(String cameraId)

** openCamera(String cameraId, StateCallback callback, Handler handler)

** openCamera(String cameraId, Executor executor, StateCallback callback)

** setTorchMode(String cameraId, boolean enabled)

* CameraDevice

** close()

** createCaptureSession(List<Surface> outputs,StateCallback callback, Handler handler)

** createCaptureSessionByOutputConfigurations(List<OutputConfiguration> outputConfigurations, CameraCaptureSession.StateCallback callback, Handler handler)

** createCaptureSession(SessionConfiguration config)

** createCaptureRequest(int templateType, Set<String> physicalCameraIdSet)

** createCaptureRequest(int templateType)

** createReprocessCaptureRequest(TotalCaptureResult inputResult)

** isSessionConfigurationSupported(SessionConfiguration sessionConfig)

* CaptureRequest

** getTag()

** getKeys()

** isReprocess()

** get(CaptureRequest.Key<T> key)

** equals(Object other)

** hashCode()

** describeContents()

** writeToParcel(Parcel dest, int flags)

* CaptureRequest.Builder

** addTarget(Surface outputTarget)

** removeTarget(Surface outputTarget)

** set(CaptureRequest.Key<T> key, T value)

** get(CaptureRequest.Key<T> key)

** setPhysicalCameraKey(CaptureRequest.Key<T> key, T value, String physicalCameraId)

** getPhysicalCameraKey(CaptureRequest.Key<T> key, String physicalCameraId)

** setTag(Object tag)

** build()

* CameraCaptureSession

** getDevice()

** prepare(Surface surface)

** capture(CaptureRequest request, CameraCaptureSession.CaptureCallback callback, Handler handler)

** captureSingleRequest(CaptureRequest request, Executor executor, CameraCaptureSession.CaptureCallback callback)

** captureBurst(List<CaptureRequest> requests, CameraCaptureSession.CaptureCallback callback, Handler handler)

** captureBurstRequests(List<CaptureRequest> requests, Executor executor, CameraCaptureSession.CaptureCallback callback)

** setRepeatingRequest(CaptureRequest request, CameraCaptureSession.CaptureCallback callback, Handler handler)

** setSingleRepeatingRequest(CaptureRequest request, Executor executor, CameraCaptureSession.CaptureCallback callback)

** setRepeatingBurst(List<CaptureRequest> requests, CameraCaptureSession.CaptureCallback callback, Handler handler)

** setRepeatingBurstRequests(List<CaptureRequest> requests, Executor executor, CameraCaptureSession.CaptureCallback callback)

** stopRepeating()

** abortCaptures()

** updateOutputConfiguration(OutputConfiguration config)

** isReprocessable()

** getInputSurface()

** close()

* ImageReader

** getWidth()

** getHeight()

** getImageFormat()

** getMaxImages()

** getSurface()

** acquireLatestImage()

** acquireNextImage()

** setOnImageAvailableListener(ImageReader.OnImageAvailableListener listener, Handler handler)

** close()

** discardFreeBuffers()

** finalize()

* SessionConfiguration

** getSessionConfiguration()

** writeToParcel(Parcel dest, int flags)

** describeContents()

** equals(Object obj)

** hashCode()

** getSessionType()

** getOutputConfigurations()

** getStateCallback()

** getExecutor()

** setInputConfiguration(InputConfiguration input)

** getInputConfiguration()

** setSessionParameters(CaptureRequest params)

** getSessionParameters()
7 changes: 6 additions & 1 deletion docs/modules/manual-testing/pages/device-controls.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ image:manual-testing:save-input-sensitive-data-closeup.png[width=300,alt="Select

== Image injection

To xref:manual-testing:test-your-app-camera.adoc[test your in-app camera], select *Image Injection*, then add an image to the injection library and select *Inject*.
To test your in-app camera, select *Image Injection*, then add an image to the injection library and select *Inject*.

[IMPORTANT]
====
Follow xref:manual-testing:test-your-app-camera.adoc[this guide] for more details on how to use image injection.
====

image:manual-testing:image-injection-closeup.png[width=500, alt="A manual session with a closeup of image injection."]

Expand Down
45 changes: 42 additions & 3 deletions docs/modules/manual-testing/pages/test-your-app-camera.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
= Test your app camera
:navtitle: Test your app camera
= Use image injection
:navtitle: Use image injection

Learn how to test your app camera using image injection, so you can ensure end-users can take photos or scan QR codes with your app.

== Before you start

You'll need to enable *Instrument application for camera injection* when xref:manual-testing:install-an-app.adoc[installing your app] before you can test your in-app camera.
There are 2 ways to enable image injection for your app:

* Either enable *Instrument application for camera injection* when xref:manual-testing:install-an-app.adoc[installing your app] before you test your in-app camera.
* Or follow xref:apps:image-injection-sdk/add-the-sdk-to-your-android-app.adoc[this guide] to add Kobiton image injection SDK into your Android apps.
+
[IMPORTANT]
====
Do not enable *Instrument application for camera injection* when installing an app that already has image injection SDK added.
====

== Add an image to the library

Expand All @@ -26,3 +34,34 @@ To inject an image into your app, launch the app and open the in-app camera. Cho
image:manual-testing:image-injection-closeup.png[width=500, alt="A close-up of the image injection library containing one image."]

When you're finished, select *Reset Camera* to stop image injection.

== Limitations

* Image Injection is available in a manual session only.

* The Reset Camera button on the Image Injection dialog is always available even when no image is injected.

* When injecting an image into an app that has not implemented the custom SDK or has not enabled image injection via instrumentation when installing, the system still sends an inject successfully message.

* Images cannot be injected into some Android applications due to the immense number of required libraries, we currently support the most common libraries. If you encounter issues, please contact our Support team through support@kobiton.com.

* App instrumentation is not working on a few Android applications, especially those applications that are obfuscated with DexGuard. For these apps, xref:apps:image-injection-sdk/add-the-sdk-to-your-android-app.adoc[add the image injection SDK] instead.

* When using image injection, the injected image is rotated.

* The injected image is zoomed a little when in use, compared to the actual size.

* No image size in the image injection control's UI.

== Known issues

The application with custom SDK crashes when attempting to start the camera services.

*Cause*: The custom SDK utilizes hidden APIs from Android, which may not be turned on and cause the app to crash.

*Solution*: Enable a Cleanup Policy with *Device settings will be reset* option checked. If no Cleanup Policy is enabled, enter the following command in xref:manual-testing:device-controls.adoc#_adb_shell[adb shell]:

[source]
----
settings put global hidden_api_policy 1
----
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/release-notes/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* All releases

** xref:all-releases/4_9_1S.adoc[]
** xref:all-releases/4_9.adoc[]
** xref:all-releases/4_8.adoc[]
** xref:all-releases/4_7S.adoc[]
Expand Down
Loading
Loading