Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#constants) \| [Inherited Constants](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#inhconstants) \| [Fields](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#lfields) \| [Ctors](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#pubctors) \| [Methods](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#inhmethods)

# PackageInstaller.SessionParams

*** ** * ** ***


`
public
static


class
PackageInstaller.SessionParams
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.pm.PackageInstaller.SessionParams |

<br />

*** ** * ** ***

Parameters for creating a new `https://developer.android.com/reference/android/content/pm/PackageInstaller.Session`.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_FULL_INSTALL` Mode for an install session whose staged APKs should fully replace any existing APKs for the target app. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_INHERIT_EXISTING` Mode for an install session that should inherit any existing APKs for the target app, unless they have been explicitly overridden (based on split name) by the session. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DEFAULT` Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set the state of a permission. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DENIED` Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set the state of a permission. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_GRANTED` Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set the state of a permission. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_NOT_REQUIRED` This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)` to indicate that user action is not required for this install. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_REQUIRED` This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)` to indicate that user action is required for this install. |
| `int` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_UNSPECIFIED` This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)` to indicate that user action is unspecified for this install. |

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams>` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#CREATOR` |
| ` public static final https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#RESTRICTED_PERMISSIONS_ALL` Special constant to refer to all restricted permissions. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#SessionParams(int)(int mode) ` Construct parameters for a new package install session. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setAppIcon(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap appIcon) ` Optionally set an icon representing the app being installed. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setAppLabel(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence appLabel) ` Optionally set a label representing the app being installed. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setAppPackageName(java.lang.String)(https://developer.android.com/reference/java/lang/String appPackageName) ` Optionally set the package name of the app being installed. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setApplicationEnabledSettingPersistent()() ` Request to keep the original application enabled setting. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setAutoInstallDependenciesEnabled(boolean)(boolean enableAutoInstallDependencies) ` *This method was deprecated in API level 37. The automatic dependency installation feature is no longer supported.* |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setAutoRevokePermissionsMode(boolean)(boolean shouldAutoRevoke) ` *This method was deprecated in API level 31. No longer used* |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setDontKillApp(boolean)(boolean dontKillApp) ` Requests that the system not kill any of the package's running processes as part of a `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_INHERIT_EXISTING` session in which splits being added. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setExtensionParams(android.os.PersistableBundle)(https://developer.android.com/reference/android/os/PersistableBundle extensionParams) ` Optionally called to provide a set of parameters to pass directly to the developer verification service provider (a.k.a., the verifier) to provide any additional context regarding the pending verification. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setInstallLocation(int)(int installLocation) ` Provide value of `https://developer.android.com/reference/android/content/pm/PackageInfo#installLocation`, which may be used to determine where the app will be staged. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setInstallReason(int)(int installReason) ` Set the reason for installing this package. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setInstallScenario(int)(int installScenario) ` Sets the install scenario for this session, which describes the expected user journey. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setInstallerPackageName(java.lang.String)(https://developer.android.com/reference/java/lang/String installerPackageName) ` Set the installer package for the app. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setMultiPackage()() ` Set this session to be the parent of a multi-package install. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setOriginatingUid(int)(int originatingUid) ` Sets the UID that initiated the package installation. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setOriginatingUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri originatingUri) ` Optionally set the URI where this package was downloaded from. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPackageSource(int)(int packageSource) ` Optionally indicate the package source of the app being installed. |
| ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String permissionName, int state) ` Sets the state of permissions for the package at installation. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setReferrerUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri referrerUri) ` Optionally set the URI that referred you to install this package. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequestUpdateOwnership(boolean)(boolean enable) ` Optionally indicate whether the package being installed needs the update ownership enforcement. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)(int requireUserAction) ` Optionally indicate whether user action should be required when the session is committed. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setSize(long)(long sizeBytes) ` Optionally indicate the total size (in bytes) of all APKs that will be delivered in this session. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setUnarchiveId(int)(int unarchiveId) ` Used to set the unarchive ID received as part of an `https://developer.android.com/reference/android/content/Intent#ACTION_UNARCHIVE_PACKAGE`. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setWhitelistedRestrictedPermissions(java.util.Set<java.lang.String>)(https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String> permissions) ` Sets which restricted permissions to be allowlisted for the app. |
| ` void` | ` https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Constants

### MODE_FULL_INSTALL

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MODE_FULL_INSTALL
```

Mode for an install session whose staged APKs should fully replace any
existing APKs for the target app.

<br />

Constant Value:

1
(0x00000001)


### MODE_INHERIT_EXISTING

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MODE_INHERIT_EXISTING
```

Mode for an install session that should inherit any existing APKs for the
target app, unless they have been explicitly overridden (based on split
name) by the session. For example, this can be used to add one or more
split APKs to an existing installation.


If there are no existing APKs for the target app, this behaves like
`https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_FULL_INSTALL`.

<br />

Constant Value:

2
(0x00000002)


### PERMISSION_STATE_DEFAULT

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int PERMISSION_STATE_DEFAULT
```

Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set
the state of a permission. This indicates no preference by the installer, relying on
the device's default policy to set the grant state of the permission.

<br />

Constant Value:

0
(0x00000000)


### PERMISSION_STATE_DENIED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int PERMISSION_STATE_DENIED
```

Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set
the state of a permission. This indicates the installers wants to deny the permission
by default to the package being installed. The user and other actors in the system may
still be able to grant the permission after installation.

<br />

Constant Value:

2
(0x00000002)


### PERMISSION_STATE_GRANTED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int PERMISSION_STATE_GRANTED
```

Value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setPermissionState(java.lang.String,%20int)` to set
the state of a permission. This indicates the installers wants to automatically grant
the permission to the package being installed. The user and other actors in the system
may still be able to deny the permission after installation.

<br />

Constant Value:

1
(0x00000001)


### USER_ACTION_NOT_REQUIRED

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int USER_ACTION_NOT_REQUIRED
```

This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)`
to indicate that user action is not required for this install.

<br />

Constant Value:

2
(0x00000002)


### USER_ACTION_REQUIRED

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int USER_ACTION_REQUIRED
```

This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)`
to indicate that user action is required for this install.

<br />

Constant Value:

1
(0x00000001)


### USER_ACTION_UNSPECIFIED

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int USER_ACTION_UNSPECIFIED
```

This value is passed by the installer to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)`
to indicate that user action is unspecified for this install.
`requireUserAction` also defaults to this value unless modified by
`https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)`

<br />

Constant Value:

0
(0x00000000)


## Fields

### CREATOR

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<PackageInstaller.SessionParams> CREATOR
```

<br />

<br />

### RESTRICTED_PERMISSIONS_ALL

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Set<String> RESTRICTED_PERMISSIONS_ALL
```

Special constant to refer to all restricted permissions.

<br />

## Public constructors

### SessionParams

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SessionParams (int mode)
```

Construct parameters for a new package install session.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: one of `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_FULL_INSTALL` or `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_INHERIT_EXISTING` describing how the session should interact with an existing app. <br /> |

## Public methods

### describeContents

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### setAppIcon

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAppIcon (Bitmap appIcon)
```

Optionally set an icon representing the app being installed. This should
be roughly `https://developer.android.com/reference/android/app/ActivityManager#getLauncherLargeIconSize()` in both
dimensions.

<br />

| Parameters ||
|---|---|
| `appIcon` | `Bitmap`: This value may be `null`. <br /> |

### setAppLabel

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAppLabel (CharSequence appLabel)
```

Optionally set a label representing the app being installed.

This value will be trimmed to the first 1000 characters.

<br />

| Parameters ||
|---|---|
| `appLabel` | `CharSequence`: This value may be `null`. <br /> |

### setAppPackageName

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAppPackageName (String appPackageName)
```

Optionally set the package name of the app being installed. It's strongly
recommended that you provide this value when known, so that observers can
communicate installing apps to users.


If the APKs staged in the session aren't consistent with this package
name, the install will fail. Regardless of this value, all APKs in the
app must have the same package name.

<br />

| Parameters ||
|---|---|
| `appPackageName` | `String`: This value may be `null`. <br /> |

### setApplicationEnabledSettingPersistent

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setApplicationEnabledSettingPersistent ()
```

Request to keep the original application enabled setting. This will prevent the
application from being enabled if it was previously in a disabled state.

<br />

### setAutoInstallDependenciesEnabled

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAutoInstallDependenciesEnabled (boolean enableAutoInstallDependencies)
```


**This method was deprecated
in API level 37.**   

The automatic dependency installation feature is no longer supported.

Optionally indicate whether missing SDK or static shared library dependencies should be
automatically fetched and installed when installing an app that wants to use these
dependencies.

This feature is enabled by default. Note that in the case of a multi-package
installation session, no dependencies will be automatically installed even if this field
is set to true.

<br />

| Parameters ||
|---|---|
| `enableAutoInstallDependencies` | `boolean`: `true` to enable auto-installation of missing SDK or static shared library dependencies, `false` to disable and fail immediately if dependencies aren't already installed. <br /> |

### setAutoRevokePermissionsMode

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAutoRevokePermissionsMode (boolean shouldAutoRevoke)
```


**This method was deprecated
in API level 31.**   

No longer used

Sets whether permissions should be auto-revoked if this package is unused for an
extended periodd of time.

It's disabled by default but generally the installer should enable it for most packages,
excluding only those where doing so might cause breakage that cannot be easily addressed
by simply re-requesting the permission(s).

If user explicitly enabled or disabled it via settings, this call is ignored.

<br />

| Parameters ||
|---|---|
| `shouldAutoRevoke` | `boolean`: whether permissions should be auto-revoked. <br /> |

### setDontKillApp

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setDontKillApp (boolean dontKillApp)
```

Requests that the system not kill any of the package's running
processes as part of a `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#MODE_INHERIT_EXISTING`
session in which splits being added. By default, all installs will
result in the package's running processes being killed before the
install completes.

<br />

| Parameters ||
|---|---|
| `dontKillApp` | `boolean`: set to `true` to request that the processes belonging to the package not be killed as part of this install. <br /> |

### setExtensionParams

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public void setExtensionParams (PersistableBundle extensionParams)
```

Optionally called to provide a set of parameters to pass directly to the developer
verification service provider (a.k.a., the verifier) to provide any additional context
regarding the pending verification. The structure of this bundle will be specific to the
implementation of the verifier, so callers can determine the verifier by calling
`https://developer.android.com/reference/android/content/pm/PackageInstaller#getDeveloperVerificationServiceProvider()`.

<br />

| Parameters ||
|---|---|
| `extensionParams` | `PersistableBundle`: This value cannot be `null`. <br /> |

### setInstallLocation

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setInstallLocation (int installLocation)
```

Provide value of `https://developer.android.com/reference/android/content/pm/PackageInfo#installLocation`, which may be used
to determine where the app will be staged. Defaults to
`https://developer.android.com/reference/android/content/pm/PackageInfo#INSTALL_LOCATION_INTERNAL_ONLY`.

<br />

| Parameters ||
|---|---|
| `installLocation` | `int` <br /> |

### setInstallReason

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setInstallReason (int installReason)
```

Set the reason for installing this package.


The install reason should be a pre-defined integer. The behavior is
undefined if other values are used.

<br />

| Parameters ||
|---|---|
| `installReason` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_UNKNOWN` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_POLICY` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_DEVICE_RESTORE` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_DEVICE_SETUP` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_USER` |

**See also:**

- `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_UNKNOWN`
- `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_POLICY`
- `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_DEVICE_RESTORE`
- `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_DEVICE_SETUP`
- `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_REASON_USER`

### setInstallScenario

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setInstallScenario (int installScenario)
```

Sets the install scenario for this session, which describes the expected user journey.

<br />

| Parameters ||
|---|---|
| `installScenario` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_SCENARIO_DEFAULT` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_SCENARIO_FAST` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_SCENARIO_BULK` - `https://developer.android.com/reference/android/content/pm/PackageManager#INSTALL_SCENARIO_BULK_SECONDARY` |

### setInstallerPackageName

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setInstallerPackageName (String installerPackageName)
```

Set the installer package for the app.

By default this is the app that created the `https://developer.android.com/reference/android/content/pm/PackageInstaller` object.

Note: Only applications with `https://developer.android.com/reference/android/Manifest.permission#INSTALL_PACKAGES`
permission are allowed to set an installer that is not the caller's own installer
package name, otherwise it will cause a `https://developer.android.com/reference/java/lang/SecurityException` when creating the
install session.

<br />

| Parameters ||
|---|---|
| `installerPackageName` | `String`: The name of the installer package, its length must be less than `255`, otherwise it will be invalid. This value may be `null`. <br /> |

### setMultiPackage

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setMultiPackage ()
```

Set this session to be the parent of a multi-package install.

A multi-package install session contains no APKs and only references other install
sessions via ID. When a multi-package session is committed, all of its children
are committed to the system in an atomic manner. If any children fail to install,
all of them do, including the multi-package session.

<br />

### setOriginatingUid

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOriginatingUid (int originatingUid)
```

Sets the UID that initiated the package installation. This is informational
and may be used as a signal for anti-malware purposes.

<br />

| Parameters ||
|---|---|
| `originatingUid` | `int` <br /> |

### setOriginatingUri

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOriginatingUri (Uri originatingUri)
```

Optionally set the URI where this package was downloaded from. This is
informational and may be used as a signal for anti-malware purposes.

<br />

| Parameters ||
|---|---|
| `originatingUri` | `Uri`: This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/Intent#EXTRA_ORIGINATING_URI`

### setPackageSource

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPackageSource (int packageSource)
```

Optionally indicate the package source of the app being installed. This is
informational and may be used as a signal by the system.

An installer should specify `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_OTHER` if no other package source
constant adequately reflects the source for this session.

The default value is `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_UNSPECIFIED`.

<br />

| Parameters ||
|---|---|
| `packageSource` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_UNSPECIFIED` - `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_STORE` - `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_LOCAL_FILE` - `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_DOWNLOADED_FILE` - `https://developer.android.com/reference/android/content/pm/PackageInstaller#PACKAGE_SOURCE_OTHER` |

### setPermissionState

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PackageInstaller.SessionParams setPermissionState (String permissionName, 
                int state)
```

Sets the state of permissions for the package at installation.

<br />

Granting any runtime permissions require the `android.Manifest.permission#INSTALL_GRANT_RUNTIME_PERMISSIONS` permission to be held by the caller. Revoking runtime permissions is not allowed, even during app update sessions.

<br />

Holders without the permission are allowed to change the following special permissions:

<br />

On platform `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`:

- `https://developer.android.com/reference/android/Manifest.permission#USE_FULL_SCREEN_INTENT`

Install time permissions, which cannot be revoked by the user, cannot be changed by the installer.

<br />

See [Permissions on Android](https://developer.android.com/guide/topics/permissions/overview) for more information.

<br />

<br />

| Parameters ||
|---|---|
| `permissionName` | `String`: The permission to change state for. This value cannot be `null`. <br /> |
| `state` | `int`: Either `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DEFAULT`, `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_GRANTED`, or `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DENIED` to set the permission to. Value is one of the following: - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DEFAULT` - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_GRANTED` - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#PERMISSION_STATE_DENIED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams` | This object for easier chaining. This value cannot be `null`. <br /> |

### setReferrerUri

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setReferrerUri (Uri referrerUri)
```

Optionally set the URI that referred you to install this package. This is
informational and may be used as a signal for anti-malware purposes.

<br />

| Parameters ||
|---|---|
| `referrerUri` | `Uri`: This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/Intent#EXTRA_REFERRER`

### setRequestUpdateOwnership

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRequestUpdateOwnership (boolean enable)
```

Optionally indicate whether the package being installed needs the update ownership
enforcement. Once the update ownership enforcement is enabled, the other installers
will need the user action to update the package even if the installers have been
granted the `https://developer.android.com/reference/android/Manifest.permission#INSTALL_PACKAGES`
permission. Default to `false`.

The update ownership enforcement can only be enabled on initial installation. Set
this to `true` on package update is a no-op.

Note: To enable the update ownership enforcement, the installer must have the
`https://developer.android.com/reference/android/Manifest.permission#ENFORCE_UPDATE_OWNERSHIP`
permission.


Requires `https://developer.android.com/reference/android/Manifest.permission#ENFORCE_UPDATE_OWNERSHIP`

<br />

| Parameters ||
|---|---|
| `enable` | `boolean` <br /> |

### setRequireUserAction

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setRequireUserAction (int requireUserAction)
```

Optionally indicate whether user action should be required when the session is
committed.


Defaults to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_UNSPECIFIED` unless otherwise set. When unspecified for
installers using the
`https://developer.android.com/reference/android/Manifest.permission#REQUEST_INSTALL_PACKAGES`
permission will behave as if set to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_REQUIRED`, and
`https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_NOT_REQUIRED` otherwise. When `requireUserAction` is set to
`https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_REQUIRED`, installers will receive a
`https://developer.android.com/reference/android/content/pm/PackageInstaller#STATUS_PENDING_USER_ACTION` callback once the session is committed, indicating
that user action is required for the install to proceed.


For installers that have been granted the
`https://developer.android.com/reference/android/Manifest.permission#REQUEST_INSTALL_PACKAGES`
permission, user action will not be required when all of the following conditions are
met:

- `requireUserAction` is set to `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_NOT_REQUIRED`.
- The app being installed targets:
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q` or higher on Android S (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#S`)
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#R` or higher on Android T (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`)
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#S` or higher on Android U (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`)
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or higher on Android V (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM`)
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE` or higher on Android B (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#BAKLAVA`)
  - `https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM` or higher on Android C (`https://developer.android.com/reference/android/os/Build.VERSION_CODES#CINNAMON_BUN`)
- The installer is:
  - The `https://developer.android.com/reference/android/content/pm/InstallSourceInfo#getUpdateOwnerPackageName()` of an existing version of the app (in other words, this install session is an app update) if the update ownership enforcement is enabled.
  - The `https://developer.android.com/reference/android/content/pm/InstallSourceInfo#getInstallingPackageName()` of an existing version of the app (in other words, this install session is an app update) if the update ownership enforcement isn't enabled.
  - Updating itself.
- The installer declares the `https://developer.android.com/reference/android/Manifest.permission#UPDATE_PACKAGES_WITHOUT_USER_ACTION` permission.


Note: The target API level requirement will advance in future Android versions.
Session owners should always be prepared to handle `https://developer.android.com/reference/android/content/pm/PackageInstaller#STATUS_PENDING_USER_ACTION`.

<br />

| Parameters ||
|---|---|
| `requireUserAction` | `int`: whether user action should be required. Value is one of the following: - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_UNSPECIFIED` - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_REQUIRED` - `https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#USER_ACTION_NOT_REQUIRED` |

### setSize

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSize (long sizeBytes)
```

Optionally indicate the total size (in bytes) of all APKs that will be
delivered in this session. The system may use this to ensure enough disk
space exists before proceeding, or to estimate container size for
installations living on external storage.

<br />

| Parameters ||
|---|---|
| `sizeBytes` | `long` <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/pm/PackageInfo#INSTALL_LOCATION_AUTO`
- `https://developer.android.com/reference/android/content/pm/PackageInfo#INSTALL_LOCATION_PREFER_EXTERNAL`

### setUnarchiveId

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setUnarchiveId (int unarchiveId)
```

Used to set the unarchive ID received as part of an
`https://developer.android.com/reference/android/content/Intent#ACTION_UNARCHIVE_PACKAGE`.

The ID should be retrieved from the unarchive intent and passed into the
session that's being created to unarchive the app in question. Used to link the unarchive
intent and the install session to disambiguate.

<br />

| Parameters ||
|---|---|
| `unarchiveId` | `int` <br /> |

### setWhitelistedRestrictedPermissions

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setWhitelistedRestrictedPermissions (Set<String> permissions)
```

Sets which restricted permissions to be allowlisted for the app. Allowlisting
is not granting the permissions, rather it allows the app to hold permissions
which are otherwise restricted. Allowlisting a non restricted permission has
no effect.

Permissions can be hard restricted which means that the app cannot hold
them or soft restricted where the app can hold the permission but in a weaker
form. Whether a permission is `https://developer.android.com/reference/android/content/pm/PermissionInfo#FLAG_HARD_RESTRICTED` or `https://developer.android.com/reference/android/content/pm/PermissionInfo#FLAG_SOFT_RESTRICTED`
depends on the permission declaration. Allowlisting a hard restricted permission
allows the app to hold that permission and allowlisting a soft restricted
permission allows the app to hold the permission in its full, unrestricted form.

Permissions can also be immutably restricted which means that the allowlist
state of the permission can be determined only at install time and cannot be
changed on updated or at a later point via the package manager APIs.

Initially, all restricted permissions are allowlisted but you can change
which ones are allowlisted by calling this method or the corresponding ones
on the `https://developer.android.com/reference/android/content/pm/PackageManager`. Only soft or hard restricted permissions on the current
Android version are supported and any invalid entries will be removed.

<br />

| Parameters ||
|---|---|
| `permissions` | `Set`: This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/pm/PackageManager#addWhitelistedRestrictedPermission(java.lang.String,%20java.lang.String,%20int)`
- `https://developer.android.com/reference/android/content/pm/PackageManager#removeWhitelistedRestrictedPermission(java.lang.String,%20java.lang.String,%20int)`

### writeToParcel

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |