# CallingAppInfo

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/provider/CallingAppInfo.kt+class:androidx.credentials.provider.CallingAppInfo) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***

<br />

```
public final class CallingAppInfo
```

<br />

*** ** * ** ***

Information pertaining to the calling application.

## Summary

| ### Public fields |
|---|---|
| `final lateinit @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/SigningInfo.html` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#signingInfo()` the signingInfo associated with the calling app, added at API level 28 |

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/androidx/annotation/VisibleForTesting @https://developer.android.com/reference/androidx/annotation/DeprecatedSinceApi(api = 28, message = "Use the SigningInfo based constructor instead") https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#CallingAppInfo(kotlin.String,kotlin.collections.List,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/Signature.html> signatures, https://developer.android.com/reference/java/lang/String.html origin )` Constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo` |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 28) @https://developer.android.com/reference/androidx/annotation/VisibleForTesting https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#CallingAppInfo(kotlin.String,android.content.pm.SigningInfo,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/SigningInfo.html signingInfo, https://developer.android.com/reference/java/lang/String.html origin )` Constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html privilegedAllowlist)` Returns the origin of the calling app. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getPackageName()()` the calling package name of the calling app |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/SigningInfo.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 28) https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getSigningInfo()()` the signingInfo associated with the calling app, added at API level 28 |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/provider/SigningInfoCompat` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getSigningInfoCompat()()` the signing information associated with the calling app, which can be used across all Android API levels |
| `int` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#isOriginPopulated()()` Returns true if the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#origin()` is populated, and false otherwise. |

## Public fields

### signingInfo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final lateinit @NonNull SigningInfo signingInfo
```

the signingInfo associated with the calling app, added at API level 28

## Public constructors

### CallingAppInfo

```
@VisibleForTesting
@DeprecatedSinceApi(api = 28, message = "Use the SigningInfo based constructor instead")
public CallingAppInfo(
    @NonNull String packageName,
    @NonNull List<@NonNull Signature> signatures,
    String origin
)
```

Constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName` | the calling package name of the calling app |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/Signature.html> signatures` | the app signatures, which should be retrieved from the app's `https://developer.android.com/reference/android/content/pm/PackageInfo.html#signatures` |
| `https://developer.android.com/reference/java/lang/String.html origin` | the origin of the calling app. This is only set when a privileged app like a browser, calls on behalf of another application. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#(kotlin.String,kotlin.collections.List,kotlin.String)` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If the class is initialized with a null `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#signingInfo()` on Android API 28 and above |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#(kotlin.String,kotlin.collections.List,kotlin.String)` is empty |

### CallingAppInfo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
@RequiresApi(value = 28)
@VisibleForTesting
public CallingAppInfo(
    @NonNull String packageName,
    @NonNull SigningInfo signingInfo,
    String origin
)
```

Constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName` | the calling package name of the calling app |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/pm/SigningInfo.html signingInfo` | the signingInfo associated with the calling app |
| `https://developer.android.com/reference/java/lang/String.html origin` | the origin of the calling app. This is only set when a privileged app like a browser, calls on behalf of another application. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#(kotlin.String,android.content.pm.SigningInfo,kotlin.String)` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If the class is initialized with a null `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#(kotlin.String,android.content.pm.SigningInfo,kotlin.String)` on Android P and above |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#(kotlin.String,android.content.pm.SigningInfo,kotlin.String)` is empty |

## Public methods

### equals

```
public boolean equals(Object other)
```

### getOrigin

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final String getOrigin(@NonNull String privilegedAllowlist)
```

Returns the origin of the calling app. This is only non-null if a privileged app like a browser calls Credential Manager APIs on behalf of another application.

Additionally, in order to get the origin, the credential provider must provide an allowlist of privileged browsers/apps that it trusts. This allowlist must be in the form of a valid, non-empty JSON. The origin will only be returned if the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#packageName()` and the SHA256 hash of the newest signature obtained from the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#signingInfo()`, is present in the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)`.

Packages that are signed with multiple signers will only receive the origin if all of the signatures are present in the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)`.

The format of this `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)` JSON must adhere to the following sample.

```
{"apps": [
   {
      "type": "android",
      "info": {
         "package_name": "com.example.myapp",
         "signatures" : [
         {"build": "release",
             "cert_fingerprint_sha256": "59:0D:2D:7B:33:6A:BD:FB:54:CD:3D:8B:36:8C:5C:3A:
             7D:22:67:5A:9A:85:9A:6A:65:47:FD:4C:8A:7C:30:32"
         },
         {"build": "userdebug",
         "cert_fingerprint_sha256": "59:0D:2D:7B:33:6A:BD:FB:54:CD:3D:8B:36:8C:5C:3A:7D:
         22:67:5A:9A:85:9A:6A:65:47:FD:4C:8A:7C:30:32"
         }]
      }
    }
]}
```

All keys in the JSON must be exactly as stated in the sample above. Note that if the build for a given fingerprint is specified as 'userdebug', that fingerprint will only be considered if the device is on a 'userdebug' build, as determined by `https://developer.android.com/reference/android/os/Build.html#TYPE`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)` is empty, or an invalid JSON, or does not follow the format detailed above |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If the origin is non-null, but the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#packageName()` and `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#signingInfo()` do not have a match in the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#getOrigin(kotlin.String)` |

### getPackageName

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final @NonNull String getPackageName()
```

the calling package name of the calling app

### getSigningInfo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
@RequiresApi(value = 28)
public final @NonNull SigningInfo getSigningInfo()
```

the signingInfo associated with the calling app, added at API level 28

### getSigningInfoCompat

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.5.0)

```
public final @NonNull SigningInfoCompat getSigningInfoCompat()
```

the signing information associated with the calling app, which can be used across all Android API levels

### hashCode

```
public int hashCode()
```

### isOriginPopulated

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
public final boolean isOriginPopulated()
```

Returns true if the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#origin()` is populated, and false otherwise.

Note that the `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo#origin()` is only populated if a privileged app like a browser calls Credential Manager APIs on behalf of another application.