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 中 AdSelectionConfigRemoveAdSelectionOverrideRequest 中关联的数据的替换项。

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 的所有替换数据。

继承的方法

公共方法

覆盖 AdSelectionConfigRemoteInfo

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

针对给定的 AdSelectionConfig 替换 AdSelection API,以避免从远程服务器提取数据,并改为使用 AddAdSelectionOverrideRequest 中提供的数据。AddAdSelectionOverrideRequest 由广告 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 由广告 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 由广告 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,则表示出现了错误。