> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-sdk/android/standalone-modules/deprecated-sdks/faceauthenticator-deprecated.md).

# FaceAuthenticator (Deprecated)

## **SDK size** <a href="#vmn3vbemkr4" id="vmn3vbemkr4"></a>

A maximum of about 3.8 MB, which may decrease because of [these elements](https://github.com/combateafraude/public-docs/blob/docs-sdks/android/reduce-sdks-size.md).

## **Analytics** <a href="#id-4pkbv6lub4gk" id="id-4pkbv6lub4gk"></a>

Our SDKs by default [collect information](https://github.com/combateafraude/public-docs/blob/docs-sdks/analytics.md) about the user and running environment to better map fraudsters and understand their behaviors. We recommend keeping this collection active as the only purpose of this data is for fraud reduction, but if you wish, you can disable it by **`.setAnalyticsSettings(boolean useAnalytics)`** parameter.

## **Runtime permissions** <a href="#qawqjqi7c84f" id="qawqjqi7c84f"></a>

| Permission   | Reason                     | Required |
| ------------ | -------------------------- | -------- |
| **`CAMERA`** | To capture the user selfie | Yes      |

## Instantiating the SDK <a href="#txv7gu9vr5cl" id="txv7gu9vr5cl"></a>

First, create an object of type **`FaceAuthenticator`**. This object is for you to configure all your business rules for the SDK:

```java
FaceAuthenticator mFaceAuthenticator = new FaceAuthenticator.Builder(String mobileToken)
    // see table below
    .build();
```

> All parameters annotated with `@Nullable` can be given `null` values, useful if you want to set only one of the parameters of a single method.

### **Builder method** <a href="#id-8scp8o8duzd8" id="id-8scp8o8duzd8"></a>

| Parameter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Required                                                                                                                                                                                                                                                                                                                      |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>String mobileToken</code></strong></p><p>Usage token associated with your CAF account.</p>                                                                                                                                                                                                                                                                                                                                                                                                                      | Yes.                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setPeopleId(String peopleId)</code></strong></p><p>User identifier to perform facematch. Currently, this value accepts only the user's CPF.</p>                                                                                                                                                                                                                                                                                                                                                                | Yes.                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setAnalyticsSettings(boolean useAnalytics)</code></strong></p><p>Enables/disables data collection for <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/faceauthenticator.md#_4pkbv6lub4gk">analytics</a>.</p>                                                                                                                                                                                                                                                          | No, the default is **`true`**                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setStabilitySensorSettings(@Nullable SensorStabilitySettings sensorStabilitySettings)</code></strong></p><p>Changes the default settings of the stability sensor. Apply <strong><code>null</code></strong> if you don't want to use this sensor.</p>                                                                                                                                                                                                                                                           | No. The default time is 1000 ms and the default threshold is 0.7 m/s².                                                                                                                                                                                                                                                        |
| <p><strong><code>.setCaptureSettings(@Nullable CaptureSettings captureSettings)</code></strong></p><p>Defines the capture settings. The method accepts instances of the <strong><code>ImageCapture</code></strong> and <strong><code>VideoCapture</code></strong> classes.</p>                                                                                                                                                                                                                                                   | No. The default is **`ImageCapture`**                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setLayout(@Nullable @LayoutRes Integer layoutId)</code></strong></p><p>Replaces the default SDK layout. Create a file in your project's layout folder, copy <a href="https://gist.github.com/MiguelXCruz/030afe3af29cd257457b8931487590b3">this template</a> and make the desired changes.</p>                                                                                                                                                                                                                 | No. The default is [this](https://gist.github.com/murilofank/6984a34e8a7fc8975283b746809e8b7f)                                                                                                                                                                                                                                |
| <p><strong><code>.setMask(@DrawableRes Integer greenMask, @DrawableRes Integer whiteMask, @DrawableRes Integer redMask)</code></strong></p><p>Changes the face capture masks: SUCCESS, NORMAL, and FAIL, in that order. If you use this option, <strong>use masks with the same detection area as the face</strong>, this region is very important for the algorithm to capture.</p>                                                                                                                                             | <p>No. The mask patterns are:</p><p><a href="https://gist.github.com/murilofank/c774f56b18975ed6d0929c035b7589b3">Normal</a></p><p><a href="https://gist.github.com/murilofank/be48a6e2812da48bc9d442bf49be0f37">Success</a></p><p><a href="https://gist.github.com/murilofank/e5a6081e4b3baf65345a820dffd63406">Fail</a></p> |
| <p><strong><code>.setStyle(@StyleRes int styleResourceId)</code></strong></p><p>Replaces the SDK's default style. In your project's <em>styles.xml</em> file, copy <a href="https://gist.github.com/murilofank/3ac0f921435466fd4e0b04d683597a38">this template</a> and edit it.</p>                                                                                                                                                                                                                                              | No. The default is [this](https://gist.github.com/murilofank/3ac0f921435466fd4e0b04d683597a38)                                                                                                                                                                                                                                |
| <p><strong><code>.enableSwitchCameraButton(boolean enable)</code></strong></p><p>Enables/disables the button for the user to switch between the front and rear camera.</p>                                                                                                                                                                                                                                                                                                                                                       | No. The default is **`true`**                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setNetworkSettings(int requestTimeout)</code></strong></p><p>Sets the <em>timeout</em> interval for SDK requests.</p>                                                                                                                                                                                                                                                                                                                                                                                          | No. The default is 60 (seconds)                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.enableGoogleServices(boolean enable)</code></strong></p><p>Allows you to enable/disable features of the SDK that consume GoogleServices in the SDK, we do not recommend disabling the services because of the loss of security.</p>                                                                                                                                                                                                                                                                            | No. The default is **`true`**                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setUseEmulator(boolean use)</code></strong></p><p>Enables the use of emulators when <strong><code>true</code></strong>. When <strong><code>true</code></strong>, ADB mode is enabled together for the emulator to work correctly. It is not recommended to enable this option, use it for testing purposes only.</p>                                                                                                                                                                                           | No. The default is **`false`**                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setUseRoot(boolean use)</code></strong></p><p>Allows the use of root devices when <strong><code>true</code></strong>.</p>                                                                                                                                                                                                                                                                                                                                                                                      | No. The default is **`false`**                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setUseDeveloperMode(boolean use)</code></strong></p><p>Enables the use of developer mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                           | No. The default is **`false`**                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setUseAdb(boolean use)</code></strong></p><p>Enables Android Debug Bridge (ADB) debugging mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                     | No. The default is **`false`**                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setUseDebug(boolean use)</code></strong></p><p>Allows you to use the app in debug mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                             | No. The default is **`false`**                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setAudioSettings(boolean use)</code></strong></p><p>Enables/disables playback of SDK audios.</p>                                                                                                                                                                                                                                                                                                                                                                                                               | No. The default is **`true`**                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setAudioSettings(Integer audioResId)</code></strong></p><p>It allows you to customize the audio used by the SDK.</p>                                                                                                                                                                                                                                                                                                                                                                                           | No. The default is "Registro Facial".                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.enableBrightnessIncrease(boolean enable)</code></strong></p><p>Enables/disables the brightness increment of the device on opening the SDK.</p>                                                                                                                                                                                                                                                                                                                                                                 | No. The default is **`true`**                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setEyesClosedSettings(boolean enable, double threshold)</code></strong></p><p>Allows you to customize the SDK's open-eye validation settings. The method expects as parameter enable to enable or disable validation, and threshold, value between 0.0 and 1.0Allows you to customize the SDK's open-eye validation settings. The method expects as parameter <strong><code>enable</code></strong> to enable or disable validation, and <strong><code>threshold</code></strong>, value between 0.0 and 1.0</p> | No. The default is **`true`** and **`0.5`**                                                                                                                                                                                                                                                                                   |
| <p><strong><code>.setStage(CafStage stage)</code></strong></p><p>Allows you to choose the environment in wich the SDK will run (production, beta). The method takes as parameter an enum <strong><code>CafStage</code></strong> to select the environment:</p>                                                                                                                                                                                                                                                                   | No. The default is **`CafStage.PROD`**                                                                                                                                                                                                                                                                                        |
| **Enum**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | **Description**                                                                                                                                                                                                                                                                                                               |
| **`CafStage.PROD`**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Will use the Trust Platform **production** environment to register the SDK executions.                                                                                                                                                                                                                                        |
| **`CafStage.BETA`**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Will use the Trust Platform **beta** environment to register the SDK executions.                                                                                                                                                                                                                                              |

{% hint style="warning" %}
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
{% endhint %}

### **Security validations** <a href="#nvbnigm4xtcj" id="nvbnigm4xtcj"></a>

We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:

```java
FaceAuthenticator.Builder("mobileToken")
    .setUseEmulator(true)
    .setUseRoot(true)
    .setUseDeveloperMode(true)
    .setUseAdb(true)
    .setUseDebug(true)
    .build();
```

{% hint style="warning" %}
Disabling security validations is recommended for **testing purposes only**. For publishing your application in production, we recommend using the default settings.
{% endhint %}

## **Starting Activity**

After creating the **`FaceAuthenticator`**, start the **`FaceAuthenticatorActivity`** by passing this object as a parameter via extra intent:

```java
Intent mIntent = new Intent(context, FaceAuthenticatorActivity.class);
mIntent.putExtra(FaceAuthenticator.PARAMETER_NAME, mFaceAuthenticator);
startActivityForResult(mIntent, REQUEST_CODE);
```

## **Getting the result**

To get the **`FaceAuthenticatorResult`** object, which contains the captures taken by the SDK, override the **`onActivityResult`** method in the same activity that you started the **`FaceAuthenticatorActivity`**:

```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE) {
        if (resultCode == RESULT_OK && data != null) {
            FaceAuthenticatorResult mFaceAuthenticatorResult = (FaceAuthenticatorResult) data.getSerializableExtra(FaceAuthenticatorResult.PARAMETER_NAME);
            // verifique mFaceAuthenticatorResult.getSDKFailure() para descobrir qual foi o motivo da finalização do SDK
        } else {
            // o usuário fechou a activity
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
```

### FaceAuthenticatorResult <a href="#xzd2cuaudch3" id="xzd2cuaudch3"></a>

| Parameter                                                                                                                                                                                                                                                                                                                                                            | Allow null                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| <p><strong><code>boolean authenticated</code></strong></p><p>Flag that indicates whether the captured selfie passed face match with the photo stored on the CAF server and the respective CPF entered by the user.</p>                                                                                                                                               | No                                                                                  |
| <p><strong><code>String signedResponse</code></strong></p><p>Signed response from the CAF server that performed the facematch. Use this parameter if you want an extra layer of security, checking that the signature of the response is not broken, or caused by an intercepted request. If it is broken, there is a strong indication of request interception.</p> | Yes, in case of error                                                               |
| <p><strong><code>String trackingId</code></strong></p><p>Identifier of this execution on our servers. If possible, save this field and send it along to our API. This way we will have more data on how the user behaved during the execution.</p>                                                                                                                   | Yes, if the user sets **`useAnalytics = false`** or the analytics calls do not work |
| <p><a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/sdks-response.md"><strong><code>SDKFailure sdkFailure</code></strong></a></p><p>Object that tells you the reason for the SDK shutdown. For more information, see <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/sdks-response.md">here</a>.</p>      | Yes, in case of success                                                             |
| <p><strong><code>lensFacing: Int</code></strong></p><p>Defines the face of the camera that was used. Use <strong><code>FaceAuthenticatorResult.LENS\_FACING\_FRONT</code></strong> or <strong><code>FaceAuthenticatorResult.LENS\_FACING\_FRONT</code></strong> to validate.</p>                                                                                     | No                                                                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/android/standalone-modules/deprecated-sdks/faceauthenticator-deprecated.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
