lightbulb_outline Please take our October 2018 developer survey. Start survey
added in version 1.0.0
belongs to Maven artifact androidx.slice:slice-core:1.0.0

SliceManager

public abstract class SliceManager
extends Object

java.lang.Object
   ↳ androidx.slice.SliceManager


Class to handle interactions with Slices.

The SliceViewManager manages permissions and pinned state for slices.

Summary

Public methods

abstract int checkSlicePermission(Uri uri, int pid, int uid)

Determine whether a particular process and user ID has been granted permission to access a specific slice URI.

static SliceManager getInstance(Context context)

Get a SliceManager.

abstract List<Uri> getPinnedSlices()

Get the list of currently pinned slices for this app.

abstract void grantSlicePermission(String toPackage, Uri uri)

Grant permission to access a specific slice Uri to another package.

abstract void revokeSlicePermission(String toPackage, Uri uri)

Remove permissions to access a particular content provider Uri that were previously added with grantSlicePermission(String, Uri) for a specific target package.

Inherited methods

Public methods

checkSlicePermission

added in version 1.0.0
public abstract int checkSlicePermission (Uri uri, 
                int pid, 
                int uid)

Determine whether a particular process and user ID has been granted permission to access a specific slice URI.

Parameters
uri Uri: The uri that is being checked.

pid int: The process ID being checked against. Must be > 0.

uid int: The user ID being checked against. A uid of 0 is the root user, which will pass every permission check.

Returns
int PackageManager.PERMISSION_GRANTED if the given pid/uid is allowed to access that uri, or PackageManager.PERMISSION_DENIED if it is not.

getInstance

added in version 1.0.0
public static SliceManager getInstance (Context context)

Get a SliceManager.

Parameters
context Context

Returns
SliceManager

getPinnedSlices

added in version 1.0.0
public abstract List<Uri> getPinnedSlices ()

Get the list of currently pinned slices for this app.

Returns
List<Uri>

grantSlicePermission

added in version 1.0.0
public abstract void grantSlicePermission (String toPackage, 
                Uri uri)

Grant permission to access a specific slice Uri to another package.

Parameters
toPackage String: The package you would like to allow to access the Uri.

uri Uri: The Uri you would like to grant access to.

revokeSlicePermission

added in version 1.0.0
public abstract void revokeSlicePermission (String toPackage, 
                Uri uri)

Remove permissions to access a particular content provider Uri that were previously added with grantSlicePermission(String, Uri) for a specific target package. The given Uri will match all previously granted Uris that are the same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will not remove any prefix grants that exist at a higher level.

Parameters
toPackage String: The package you would like to allow to access the Uri.

uri Uri: The Uri you would like to revoke access to.