Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/security/PolicySpi#pubctors) \| [Protected Methods](https://developer.android.com/reference/java/security/PolicySpi#promethods) \| [Inherited Methods](https://developer.android.com/reference/java/security/PolicySpi#inhmethods)

# PolicySpi

` public abstract class PolicySpi `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.security.PolicySpi |

<br />

*** ** * ** ***

This class defines the *Service Provider Interface* (**SPI** ) for the `Policy` class. All the abstract methods in this class must be implemented by each service provider who wishes to supply a Policy implementation.

Subclass implementations of this abstract class must provide a public constructor that takes a `Policy.Parameters` object as an input parameter. This constructor also must throw an IllegalArgumentException if it does not understand the `Policy.Parameters` input.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/PolicySpi#PolicySpi()() ` |

| ### Protected methods ||
|---|---|
| ` https://developer.android.com/reference/java/security/PermissionCollection` | ` https://developer.android.com/reference/java/security/PolicySpi#engineGetPermissions(java.security.ProtectionDomain)(https://developer.android.com/reference/java/security/ProtectionDomain domain) ` Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. |
| ` https://developer.android.com/reference/java/security/PermissionCollection` | ` https://developer.android.com/reference/java/security/PolicySpi#engineGetPermissions(java.security.CodeSource)(https://developer.android.com/reference/java/security/CodeSource codesource) ` Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/security/PolicySpi#engineImplies(java.security.ProtectionDomain,%20java.security.Permission)(https://developer.android.com/reference/java/security/ProtectionDomain domain, https://developer.android.com/reference/java/security/Permission permission) ` Check whether the policy has granted a Permission to a ProtectionDomain. |
| ` void` | ` https://developer.android.com/reference/java/security/PolicySpi#engineRefresh()() ` Refreshes/reloads the policy configuration. |

### 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*.

## Public constructors

### PolicySpi

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

```
public PolicySpi ()
```

<br />

<br />

## Protected methods

### engineGetPermissions

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

```
protected PermissionCollection engineGetPermissions (ProtectionDomain domain)
```

Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain.

The default implementation of this method returns Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be overridden if the policy implementation can return a set of permissions granted to a ProtectionDomain.

<br />

| Parameters ||
|---|---|
| `domain` | `ProtectionDomain`: the ProtectionDomain to which the returned PermissionCollection has been granted. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/PermissionCollection` | a set of permissions granted to the specified ProtectionDomain. If this operation is supported, the returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types. If this operation is not supported, Policy.UNSUPPORTED_EMPTY_COLLECTION is returned. <br /> |

### engineGetPermissions

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

```
protected PermissionCollection engineGetPermissions (CodeSource codesource)
```

Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource.

The default implementation of this method returns Policy.UNSUPPORTED_EMPTY_COLLECTION object. This method can be overridden if the policy implementation can return a set of permissions granted to a CodeSource.

<br />

| Parameters ||
|---|---|
| `codesource` | `CodeSource`: the CodeSource to which the returned PermissionCollection has been granted. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/PermissionCollection` | a set of permissions granted to the specified CodeSource. If this operation is supported, the returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types. If this operation is not supported, Policy.UNSUPPORTED_EMPTY_COLLECTION is returned. <br /> |

### engineImplies

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

```
protected abstract boolean engineImplies (ProtectionDomain domain, 
                Permission permission)
```

Check whether the policy has granted a Permission to a ProtectionDomain.

<br />

| Parameters ||
|---|---|
| `domain` | `ProtectionDomain`: the ProtectionDomain to check. <br /> |
| `permission` | `Permission`: check whether this permission is granted to the specified domain. <br /> |

| Returns ||
|---|---|
| `boolean` | boolean true if the permission is granted to the domain. <br /> |

### engineRefresh

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

```
protected void engineRefresh ()
```

Refreshes/reloads the policy configuration. The behavior of this method depends on the implementation. For example, calling `refresh` on a file-based policy will cause the file to be re-read.

The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the policy implementation.

<br />