# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Constants | Inherited Constants | Fields | Ctors | Methods | Inherited Methods

# PackageInstaller.SessionParams

`public static class PackageInstaller.SessionParams`
`extends Object` `implements Parcelable`

java.lang.Object
↳ | android.content.pm.PackageInstaller.SessionParams

Parameters for creating a new `PackageInstaller.Session`.

## Summary

### Constants
`int` | `MODE_FULL_INSTALL` Mode for an install session whose staged APKs should fully replace any existing APKs for the target app.
`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.

### Inherited constants
From interface `android.os.Parcelable`
`int` | `CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` | `PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `writeToParcel(Parcel, int)`: 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 Creator<PackageInstaller.SessionParams>` | `CREATOR`
`public static final Set<String>` | `RESTRICTED_PERMISSIONS_ALL` Special constant to refer to all restricted permissions.

### Public constructors
`SessionParams(int mode)` Construct parameters for a new package install session.

### Public methods
`int` | `describeContents()` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
`void` | `setAppIcon(Bitmap appIcon)` Optionally set an icon representing the app being installed.
`void` | `setAppLabel(CharSequence appLabel)` Optionally set a label representing the app being installed.
`void` | `setAppPackageName(String appPackageName)` Optionally set the package name of the app being installed.
`void` | `setAutoRevokePermissionsMode(boolean shouldAutoRevoke)` Sets whether permissions should be auto-revoked if this package is unused for an extended periodd of time.
`void` | `setInstallLocation(int installLocation)` Provide value of `PackageInfo#installLocation`, which may be used to determine where the app will be staged.
`void` | `setInstallReason(int installReason)` Set the reason for installing this package.
`void` | `setMultiPackage()` Set this session to be the parent of a multi-package install.
`void` | `setOriginatingUid(int originatingUid)` Sets the UID that initiated the package installation.
`void` | `setOriginatingUri(Uri originatingUri)` Optionally set the URI where this package was downloaded from.
`void` | `setReferrerUri(Uri referrerUri)` Optionally set the URI that referred you to install this package.
`void` | `setSize(long sizeBytes)` Optionally indicate the total size (in bytes) of all APKs that will be delivered in this session.
`void` | `setWhitelistedRestrictedPermissions(Set<String> permissions)` Sets which restricted permissions to be whitelisted for the app.
`void` | `writeToParcel(Parcel dest, int flags)` Flatten this object in to a Parcel.

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

## Constants

### MODE_FULL_INSTALL

    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.

Constant Value: 1 (0x00000001)

### MODE_INHERIT_EXISTING

    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 `MODE_FULL_INSTALL`.

Constant Value: 2 (0x00000002)

## Fields

### CREATOR

    public static final Creator<PackageInstaller.SessionParams> CREATOR

### RESTRICTED_PERMISSIONS_ALL

    public static final Set<String> RESTRICTED_PERMISSIONS_ALL

Special constant to refer to all restricted permissions.

## Public constructors

### SessionParams

    public SessionParams (int mode)

Construct parameters for a new package install session.

Parameters
`mode` | `int`: one of `MODE_FULL_INSTALL` or `MODE_INHERIT_EXISTING` describing how the session should interact with an existing app.

## Public methods

### describeContents

    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 `writeToParcel(android.os.Parcel, int)`, the return value of this method must include the `CONTENTS_FILE_DESCRIPTOR` bit.

Returns
`int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or `CONTENTS_FILE_DESCRIPTOR`

### setAppIcon

    public void setAppIcon (Bitmap appIcon)

Optionally set an icon representing the app being installed. This should be roughly `ActivityManager#getLauncherLargeIconSize()` in both dimensions.

Parameters
`appIcon` | `Bitmap`: This value may be `null`.

### setAppLabel

    public void setAppLabel (CharSequence appLabel)

Optionally set a label representing the app being installed. This value will be trimmed to the first 1000 characters.

Parameters
`appLabel` | `CharSequence`: This value may be `null`.

### setAppPackageName

    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.

Parameters
`appPackageName` | `String`: This value may be `null`.

### setAutoRevokePermissionsMode

    public void setAutoRevokePermissionsMode (boolean shouldAutoRevoke)

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.

Parameters
`shouldAutoRevoke` | `boolean`: whether permissions should be auto-revoked.

### setInstallLocation

    public void setInstallLocation (int installLocation)

Provide value of `PackageInfo#installLocation`, which may be used to determine where the app will be staged. Defaults to `PackageInfo#INSTALL_LOCATION_INTERNAL_ONLY`.

Parameters
`installLocation` | `int`

### setInstallReason

    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.

Parameters
`installReason` | `int`: Value is `PackageManager.INSTALL_REASON_UNKNOWN`, `PackageManager.INSTALL_REASON_POLICY`, `PackageManager.INSTALL_REASON_DEVICE_RESTORE`, `PackageManager.INSTALL_REASON_DEVICE_SETUP`, `PackageManager.INSTALL_REASON_USER`, or android.content.pm.PackageManager.INSTALL_REASON_ROLLBACK

See also:

- `PackageManager.INSTALL_REASON_UNKNOWN`
- `PackageManager.INSTALL_REASON_POLICY`
- `PackageManager.INSTALL_REASON_DEVICE_RESTORE`
- `PackageManager.INSTALL_REASON_DEVICE_SETUP`
- `PackageManager.INSTALL_REASON_USER`

### setMultiPackage

    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.

### setOriginatingUid

    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.

Parameters
`originatingUid` | `int`

### setOriginatingUri

    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.

Parameters
`originatingUri` | `Uri`: This value may be `null`.

See also:

- `Intent.EXTRA_ORIGINATING_URI`

### setReferrerUri

    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.

Parameters
`referrerUri` | `Uri`: This value may be `null`.

See also:

- `Intent.EXTRA_REFERRER`

### setSize

    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.

Parameters
`sizeBytes` | `long`

See also:

- `PackageInfo.INSTALL_LOCATION_AUTO`
- `PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL`

### setWhitelistedRestrictedPermissions

    public void setWhitelistedRestrictedPermissions (Set<String> permissions)

Sets which restricted permissions to be whitelisted for the app. Whitelisting is not granting the permissions, rather it allows the app to hold permissions which are otherwise restricted. Whitelisting 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 `PermissionInfo#FLAG_HARD_RESTRICTED` or `PermissionInfo#FLAG_SOFT_RESTRICTED` depends on the permission declaration. Whitelisting a hard restricted permission allows the app to hold that permission and whitelisting 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 whitelist 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 whitelisted but you can change which ones are whitelisted by calling this method or the corresponding ones on the `PackageManager`. Only soft or hard restricted permissions on the current Android version are supported and any invalid entries will be removed.

Parameters
`permissions` | `Set`: This value may be `null`.

See also:

- `PackageManager.addWhitelistedRestrictedPermission(String, String, int)`
- `PackageManager.removeWhitelistedRestrictedPermission(String, String, int)`

### writeToParcel

    public void writeToParcel (Parcel dest,
                    int flags)

Flatten this object in to a Parcel.

Parameters
`dest` | `Parcel`: The Parcel in which the object should be written.
`flags` | `int`: Additional flags about how the object should be written. May be 0 or `Parcelable.PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of `Parcelable.PARCELABLE_WRITE_RETURN_VALUE`, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*