已在 API 级别 34 中引入
也已在广告服务扩展 4 中引入

TestAdSelectionManager

public class TestAdSelectionManager
extends Object

java.lang.Object
   ↳ android.adservices.adselection.TestAdSelectionManager


TestAdSelectionManager 为应用和广告 SDK 提供用于测试广告选择流程的 API。

这些 API 旨在用于端到端测试。只有在搭载已启用开发者选项的可调试操作系统 build 的手机上,可调试应用才会启用这些功能。

摘要

公共方法

void overrideAdSelectionConfigRemoteInfo(AddAdSelectionOverrideRequest request, Executor executor, OutcomeReceiver<ObjectException> receiver)

替换给定 AdSelectionConfig 的 AdSelection API,以避免从远程服务器提取数据,并改用 AddAdSelectionOverrideRequest 中提供的数据。

void overrideAdSelectionFromOutcomesConfigRemoteInfo(AddAdSelectionFromOutcomesOverrideRequest request, Executor executor, OutcomeReceiver<ObjectException> receiver)

替换了 AdSelectionFromOutcomesConfig 的 AdSelection API,以避免从远程服务器提取数据,并改用 AddAdSelectionFromOutcomesOverrideRequest 中提供的数据。

void removeAdSelectionConfigRemoteInfoOverride(RemoveAdSelectionOverrideRequest request, Executor executor, OutcomeReceiver<ObjectException> receiver)

移除了 Ad Selection API 中与 RemoveAdSelectionOverrideRequest 中关联数据的 AdSelectionConfig 替换项。

void removeAdSelectionFromOutcomesConfigRemoteInfoOverride(RemoveAdSelectionFromOutcomesOverrideRequest request, Executor executor, OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中与 RemoveAdSelectionOverrideRequest 中关联的数据对应的 AdSelectionFromOutcomesConfig 替换项。

void resetAllAdSelectionConfigRemoteOverrides(Executor executor, OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中 AdSelectionConfig 的所有替换数据。

void resetAllAdSelectionFromOutcomesConfigRemoteOverrides(Executor executor, OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中 AdSelectionFromOutcomesConfig 的所有替换数据。

继承的方法

Object clone()

创建并返回此对象的副本。

boolean equals(Object obj)

指示某个其他对象是否“等于”此对象。

void finalize()

当垃圾回收功能确定对某个对象没有更多引用时,由垃圾回收器针对此对象调用该方法。

final Class<?> getClass()

返回此 Object 的运行时类。

int hashCode()

返回对象的哈希代码值。

final void notify()

唤醒正在等待此对象的监控器的单个线程。

final void notifyAll()

唤醒等待此对象监视器的所有线程。

String toString()

返回对象的字符串表示。

final void wait(long timeoutMillis, int nanos)

让当前线程进入等待状态,直到其被唤醒(通常在收到通知或被中断时),或者实际经过了一定的时间为止。

final void wait(long timeoutMillis)

让当前线程进入等待状态,直到其被唤醒(通常在收到通知或被中断时),或者实际经过了一定的时间为止。

final void wait()

让当前线程进入等待状态,直到其被唤醒(通常在收到通知或被中断时)

公共方法

overrideAdSelectionConfigRemoteInfo

已在 API 级别 34 中引入
也已在广告服务扩展 4 中引入
public void overrideAdSelectionConfigRemoteInfo (AddAdSelectionOverrideRequest request, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

替换给定 AdSelectionConfig 的 AdSelection API,以避免从远程服务器提取数据,并改用 AddAdSelectionOverrideRequest 中提供的数据。AddAdSelectionOverrideRequest 由 Google Ads SDK 提供。

此方法旨在用于端到端测试。此 API 仅适用于处于调试模式且启用了开发者选项的应用。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
request AddAdSelectionOverrideRequest:此值不能为 null

executor Executor:此值不能为 null。 回调和监听器事件通过此 Executor 进行分派,便于您控制使用哪个线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供一个分派到适当线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果未为调用方启用此 API

接收器会返回 void 表示运行成功,或者返回 Exception 来指示错误。

覆盖 AdSelectionFromOutcomesConfigRemoteInfo

public void overrideAdSelectionFromOutcomesConfigRemoteInfo (AddAdSelectionFromOutcomesOverrideRequest request, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

替换了 AdSelectionFromOutcomesConfig 的 AdSelection API,以避免从远程服务器提取数据,而是改用 AddAdSelectionFromOutcomesOverrideRequest 中提供的数据。AddAdSelectionFromOutcomesOverrideRequest 由 Google Ads SDK 提供。

此方法旨在用于端到端测试。系统仅会为处于调试模式且启用了开发者选项的应用启用此 API。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
request AddAdSelectionFromOutcomesOverrideRequest:此值不能为 null

executor Executor:此值不能为 null。 通过此 Executor 分派回调和监听器事件,从而让您能够轻松控制要使用的线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供一个分派到适当线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果没有为调用方启用此 API,则会发生此错误

接收器会返回 void 表示运行成功,或者返回 Exception 来指示错误。

removeAdSelectionConfigRemoteInfoOverride

已在 API 级别 34 中引入
也已在广告服务扩展 4 中引入
public void removeAdSelectionConfigRemoteInfoOverride (RemoveAdSelectionOverrideRequest request, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中与 RemoveAdSelectionOverrideRequest 中关联的数据对应的 AdSelectionConfig 替换项。RemoveAdSelectionOverrideRequest 由广告 SDK 提供。

此方法旨在用于端到端测试。此 API 仅适用于处于调试模式且启用了开发者选项的应用。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
request RemoveAdSelectionOverrideRequest:此值不能为 null

executor Executor:此值不能为 null。 通过此 Executor 分派回调和监听器事件,从而让您能够轻松控制要使用的线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供一个分派到适当线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果没有为调用方启用此 API,则会发生此错误

接收器会返回 void 表示运行成功,或者 Exception 指示错误。

removeAdSelectionFromOutcomesConfigRemoteInfoOverride

public void removeAdSelectionFromOutcomesConfigRemoteInfoOverride (RemoveAdSelectionFromOutcomesOverrideRequest request, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

移除了 Ad Selection API 中与 RemoveAdSelectionOverrideRequest 中关联的数据的 AdSelectionFromOutcomesConfig 替换项。RemoveAdSelectionOverrideRequest 由 Google Ads SDK 提供。

此方法旨在用于端到端测试。此 API 仅适用于处于调试模式且启用了开发者选项的应用。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
request RemoveAdSelectionFromOutcomesOverrideRequest:此值不能为 null

executor Executor:此值不能为 null。 通过此 Executor 分派回调和监听器事件,从而让您能够轻松控制要使用的线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供一个分派到适当线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果未为调用方启用此 API

接收器会在运行成功时返回 void,在出现错误时返回 Exception

resetAllAdSelectionConfigRemoteOverrides

已在 API 级别 34 中引入
也已在广告服务扩展 4 中引入
public void resetAllAdSelectionConfigRemoteOverrides (Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中 AdSelectionConfig 的所有替换数据。

此方法旨在用于端到端测试。系统仅会为处于调试模式且启用了开发者选项的应用启用此 API。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
executor Executor:此值不能为 null。 通过此 Executor 分派回调和监听器事件,从而让您能够轻松控制要使用的线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供一个分派到适当线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果未为调用方启用此 API

接收器会在运行成功时返回 void,在出现错误时返回 Exception

resetAllAdSelectionFromOutcomesConfigRemoteOverrides

public void resetAllAdSelectionFromOutcomesConfigRemoteOverrides (Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

移除 Ad Selection API 中 AdSelectionFromOutcomesConfig 的所有替换数据。

此方法旨在用于端到端测试。此 API 仅适用于处于调试模式且启用了开发者选项的应用。
需要 AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE

参数
executor Executor:此值不能为 null。 通过此 Executor 分派回调和监听器事件,从而让您能够轻松控制要使用的线程。如需通过应用的主线程分派事件,可以使用 Context.getMainExecutor()。 否则,请提供分派给相应线程的 Executor

receiver OutcomeReceiver:此值不能为 null

抛出
IllegalStateException 如果未为调用方启用此 API

接收器会在运行成功时返回 void,在出现错误时返回 Exception