ContentSafetyAppService


public abstract class ContentSafetyAppService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.contentsafety.ContentSafetyAppService


Base class for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

When the content safety subsystem is enabled and an app calls ContentSafetyManager.requestContentClassification, the system service will call onClassifyContent(ClassifiableContent).

    <service android:name=".SampleContentSafetyAppService"
             android:permission="android.permission.BIND_CONTENT_SAFETY_SERVICE"
             android:privateComputeCore="true">
        <intent-filter>
            <action android:name="android.app.action.CONTENT_SAFETY_SERVICE" />
        </intent-filter>
     </service>

Summary

Constants

String ACTION_CONTENT_SAFETY_APP_SERVICE

Service action: Action for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

Inherited constants

Public constructors

ContentSafetyAppService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

abstract ContentClassificationResult onClassifyContent(ClassifiableContent content)

Called when content needs to be classified.

Inherited methods

Constants

ACTION_CONTENT_SAFETY_APP_SERVICE

Added in API level 10000
public static final String ACTION_CONTENT_SAFETY_APP_SERVICE

Service action: Action for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

Constant Value: "android.app.action.CONTENT_SAFETY_SERVICE"

Public constructors

ContentSafetyAppService

public ContentSafetyAppService ()

Public methods

onBind

Added in API level 10000
public final IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: This value may be null.

Returns
IBinder This value may be null.

onClassifyContent

Added in API level 10000
public abstract ContentClassificationResult onClassifyContent (ClassifiableContent content)

Called when content needs to be classified.

This is called on the main thread.

Parameters
content ClassifiableContent: the content to be classified.
This value cannot be null.

Returns
ContentClassificationResult the content classification result.
This value cannot be null.