QAndroidBinder 类

包裹 Android Binder 类最重要方法。 更多...

头: #include <QtCore/private/qandroidextras_p.h>
qmake: QT += core-private
Since: Qt 6.2
状态: Preliminary

该类在开发且可能改变。

公共类型

enum class CallType { Normal, OneWay }

公共函数

QAndroidBinder ()
QAndroidBinder (const QJniObject & binder )
QJniObject handle () const
virtual bool onTransact (int code , const QAndroidParcel & data , const QAndroidParcel & reply , QAndroidBinder::CallType flags )
bool transact (int code , const QAndroidParcel & data , QAndroidParcel * reply = nullptr, QAndroidBinder::CallType flags = CallType::Normal) const

详细描述

QAndroidBinder 是方便类,包裹最重要 Android Binder 方法。

When building with CMake, use the following commands to use private Qt Core APIs:

find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
					

成员类型文档编制

enum class QAndroidBinder:: CallType

此枚举用于 QAndroidBinder::transact () to describe the mode in which the IPC call is performed.

常量 描述
QAndroidBinder::CallType::Normal 0 normal IPC, meaning that the caller waits the result from the callee
QAndroidBinder::CallType::OneWay 1 one-way IPC, meaning that the caller returns immediately, without waiting for a result from the callee

成员函数文档编制

[explicit] QAndroidBinder:: QAndroidBinder ()

创建可用于履行 IPC 的新对象。

另请参阅 onTransact and transact .

QAndroidBinder:: QAndroidBinder (const QJniObject & binder )

创建新的对象从 binder Java 对象。

另请参阅 transact .

QJniObject QAndroidBinder:: handle () const

The return value is useful to call other Java API which are not covered by this wrapper

[虚拟] bool QAndroidBinder:: onTransact ( int code , const QAndroidParcel & data , const QAndroidParcel & reply , QAndroidBinder::CallType flags )

Default implementation is a stub that returns false. The user should override this method to get the transact data from the caller.

The code 是要履行的动作。 data 是由调用者发送的编组数据。
The reply 是要发送给调用者的编组数据。
The flags 是额外操作标志。

警告: This method is called from Binder's thread which is different from the thread that this object was created.

另请参阅 transact .

bool QAndroidBinder:: transact ( int code , const QAndroidParcel & data , QAndroidParcel * reply = nullptr, QAndroidBinder::CallType flags = CallType::Normal) const

履行 IPC 调用

The code 是要履行的动作。应该介于 FIRST_CALL_TRANSACTION and LAST_CALL_TRANSACTION .
The data 是要发送给目标的编组数据。
The reply (if specified) is the marshaled data to be received from the target. May be nullptr if you are not interested in the return value.
The flags 是额外操作标志。

返回 true 当成功时