From 9d844ed102f0b19779382661a171679dbc04ea70 Mon Sep 17 00:00:00 2001 From: kuailexs <952415538@qq.com> Date: Sun, 5 Nov 2023 16:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++ Makefile | 0 README.md | 20 ++++++++ func.txt | 32 +++++++++++++ include/.empty | 0 src/vendor_qti_ims.c | 0 src/vendor_qti_ims_call.c | 18 +++++++ src/vendor_qti_ims_conf.c | 5 ++ src/vendor_qti_ims_radio.c | 16 +++++++ src/vendor_qti_ims_sms.c | 80 +++++++++++++++++++++++++++++++ src/vendor_qti_plugin.c | 97 ++++++++++++++++++++++++++++++++++++++ src/vendor_qti_slot.c | 64 +++++++++++++++++++++++++ src/vendor_qti_util.c | 2 + 13 files changed, 338 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 func.txt create mode 100644 include/.empty create mode 100644 src/vendor_qti_ims.c create mode 100644 src/vendor_qti_ims_call.c create mode 100644 src/vendor_qti_ims_conf.c create mode 100644 src/vendor_qti_ims_radio.c create mode 100644 src/vendor_qti_ims_sms.c create mode 100644 src/vendor_qti_plugin.c create mode 100644 src/vendor_qti_slot.c create mode 100644 src/vendor_qti_util.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55bef22 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.S +*.rpm +*.so +*.o \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3cf8bde --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +## 尝试 ofono-vendor-qti-radio-plugin + +## 依赖项目 +1. git clone https://github.com/mer-hybris/ofono-binder-plugin -b upgrade-4.4.0 +2. git clone https://github.com/sailfishos/ofono -b upgrade-4.4.0 +3. git clone https://github.com/mer-hybris/libgbinder-radio -b upgrade-4.4.0 + +## 资料 +1. glib 继承实现 +2. G_DEFINE_TYPE用法 https://www.codenong.com/cs106693497/ +3. G_DEFINE_TYPE用法 https://blog.csdn.net/evsqiezi/article/details/83049655 +4. g_type_register_static_simple(type, "A", sizeof(A_class), A_class_init, sizeof(A), A_init, 0LL); + + +## https://docs.sailfishos.org/Reference/Architecture/ +| Area | Call chain | Notes | +| --- | --- | --- | +| Modem | [oFono](https://github.com/sailfishos/ofono)([ril driver](https://github.com/sailfishos/ofono/tree/master/ofono/drivers/ril)) <> [libgrilio](https://github.com/sailfishos/libgrilio) <> [ofono-ril-binder-plugin](https://github.com/mer-hybris/ofono-ril-binder-plugin) <> [libgbinder-radio](https://github.com/mer-hybris/libgbinder-radio) <> [libgbinder](https://github.com/mer-hybris/libgbinder) <> Android BSP HAL: android.hardware.radio | Android BSP >= 8 | +| | [oFono](https://github.com/sailfishos/ofono)([ril driver](https://github.com/sailfishos/ofono/tree/master/ofono/drivers/ril)) <> [libgrilio](https://github.com/sailfishos/libgrilio) <> socket <> Android BSP: rild | Android BSP <= 7 | +| | [oFono](https://github.com/sailfishos/ofono)<> [ofono-binder-plugin](https://github.com/mer-hybris/ofono-binder-plugin) <> ofono-vendor-qti-radio-plugin(未开源) <> [libgbinder-radio](https://github.com/mer-hybris/libgbinder-radio) <> [libgbinder](https://github.com/mer-hybris/libgbinder) <> Android BSP HAL: android.hardware.radio | for VoLTE | \ No newline at end of file diff --git a/func.txt b/func.txt new file mode 100644 index 0000000..1abe3a6 --- /dev/null +++ b/func.txt @@ -0,0 +1,32 @@ +vendor_qti_ims_call_conference_info_start_element +vendor_qti_ims_call_reg_state_update +vendor_qti_ims_call_hangup +vendor_qti_ims_call_send_dtmf +vendor_qti_ims_call_conference +vendor_qti_ims_call_conference_request_complete +vendor_qti_ims_call_swap +vendor_qti_ims_call_result_request_continue +vendor_qti_ims_call_result_request_continue_resume +vendor_qti_ims_call_result_request_continue_answer +vendor_qti_ims_call_answer +vendor_qti_ims_call_dial +vendor_qti_ims_call_handle_conference_info +vendor_qti_ims_call_handle_conf_user_deleted +vendor_qti_ims_call_handle_conf_user_info_changed +vendor_qti_ims_call_handle_state_change + +vendor_qti_ims_conf_info_state +vendor_qti_ims_conf_info_apply +vendor_qti_ims_conf_info_endpoint_status + +vendor_qti_ims_radio_registration_info +vendor_qti_ims_radio_get_reg_state_response +vendor_qti_ims_radio_send_ims_sms_response +vendor_qti_ims_radio_sip_result_response + +vendor_qti_ims_sms_send + +vendor_qti_plugin_exit +vendor_qti_plugin_init + +vendor_qti_util_markup_parse diff --git a/include/.empty b/include/.empty new file mode 100644 index 0000000..e69de29 diff --git a/src/vendor_qti_ims.c b/src/vendor_qti_ims.c new file mode 100644 index 0000000..e69de29 diff --git a/src/vendor_qti_ims_call.c b/src/vendor_qti_ims_call.c new file mode 100644 index 0000000..8265416 --- /dev/null +++ b/src/vendor_qti_ims_call.c @@ -0,0 +1,18 @@ + + +vendor_qti_ims_call_conference_info_start_element +vendor_qti_ims_call_reg_state_update +vendor_qti_ims_call_hangup +vendor_qti_ims_call_send_dtmf +vendor_qti_ims_call_conference +vendor_qti_ims_call_conference_request_complete +vendor_qti_ims_call_swap +vendor_qti_ims_call_result_request_continue +vendor_qti_ims_call_result_request_continue_resume +vendor_qti_ims_call_result_request_continue_answer +vendor_qti_ims_call_answer +vendor_qti_ims_call_dial +vendor_qti_ims_call_handle_conference_info +vendor_qti_ims_call_handle_conf_user_deleted +vendor_qti_ims_call_handle_conf_user_info_changed +vendor_qti_ims_call_handle_state_change diff --git a/src/vendor_qti_ims_conf.c b/src/vendor_qti_ims_conf.c new file mode 100644 index 0000000..0c8cb5b --- /dev/null +++ b/src/vendor_qti_ims_conf.c @@ -0,0 +1,5 @@ + + +vendor_qti_ims_conf_info_state +vendor_qti_ims_conf_info_apply +vendor_qti_ims_conf_info_endpoint_status diff --git a/src/vendor_qti_ims_radio.c b/src/vendor_qti_ims_radio.c new file mode 100644 index 0000000..6637eab --- /dev/null +++ b/src/vendor_qti_ims_radio.c @@ -0,0 +1,16 @@ + + + +typedef VendorQtiImsRadioClass VendorQtiExtClass; +typedef struct qti_ims_radio { + BinderExtPlugin parent; + int num; + +} VendorQtiImsRadio; + + +vendor_qti_ims_radio_registration_info +vendor_qti_ims_radio_get_reg_state_response +vendor_qti_ims_radio_send_ims_sms_response +vendor_qti_ims_radio_sip_result_response +vendor_qti_ims_radio_new diff --git a/src/vendor_qti_ims_sms.c b/src/vendor_qti_ims_sms.c new file mode 100644 index 0000000..7e509a0 --- /dev/null +++ b/src/vendor_qti_ims_sms.c @@ -0,0 +1,80 @@ + + +#include "binder_ext_sms_impl.h" + + +typedef GObjectClass VendorQtiImsSmsClass; +typedef struct qti_ims_sms { + GObject parent; + int cancelled; + VendorQtiImsRadio* ims_radio; + VendorQtiImsStateObject* ims_state; +} VendorQtiImsSms; + +static void qti_ims_sms_iface_init(BinderExtSmsInterface* iface); +G_DEFINE_TYPE_WITH_CODE(VendorQtiImsSms, qti_ims_sms, G_TYPE_OBJECT, +G_IMPLEMENT_INTERFACE(BINDER_EXT_TYPE_SMS, qti_ims_sms_iface_init)) + +#define QTI_TYPE_SMS qti_ims_sms_get_type() +#define QTI_IMS_SMS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, QTI_TYPE_SMS, VendorQtiImsSms) + +static +void +qti_ims_sms_init( + VendorQtiImsSms* self) +{ +} + +static +void +qti_ims_sms_class_init( + VendorQtiImsSmsClass* klass) +{ + sms_incoming_signal = g_signal_new("qti-ims-sms-incoming", + G_TYPE_FROM_CLASS (klass), + 1LL, 0LL, 0LL, 0LL, 0LL, 4LL, 2, 68LL); + sms_status_report_signal = g_signal_new("qti-ims-sms-status-report", + G_TYPE_FROM_CLASS (klass), + 1LL, 0LL, 0LL, 0LL, 0LL, 4LL, 3, 68LL); +} + + +/***************************** + * Interface + * ***************************/ +guint vendor_qti_ims_sms_send(BinderExtSms* ext, const char* smsc, const void* pdu, + gsize pdu_len, guint msg_ref, BINDER_EXT_SMS_SEND_FLAGS flags, + BinderExtSmsSendFunc complete, GDestroyNotify destroy, + void* user_data); +void vendor_qti_ims_sms_cancel(BinderExtSms* ext, guint id); +void vendor_qti_ims_sms_ack_report(BinderExtSms* ext, guint msg_ref, gboolean ok); +void vendor_qti_ims_sms_ack_incoming(BinderExtSms* ext, gboolean ok); +gulong vendor_qti_ims_sms_add_report_handler(BinderExtSms* ext, + BinderExtSmsReportFunc handler, void* user_data); +gulong vendor_qti_ims_sms_add_incoming_handler(BinderExtSms* ext, + BinderExtSmsIncomingFunc handler, void* user_data); +void vendor_qti_ims_sms_remove_handler(BinderExtSms* ext, gulong id); + + +static void qti_ims_sms_iface_init(BinderExtSmsInterface* iface){ + iface->flags |= BINDER_EXT_SMS_INTERFACE_FLAG_IMS_SUPPORT | BINDER_EXT_SMS_INTERFACE_FLAG_IMS_REQUIRED; + iface->version = 1; + iface->send = vendor_qti_ims_sms_send; + iface->cancel = vendor_qti_ims_sms_cancel; + iface->ack_report = vendor_qti_ims_sms_ack_report; + iface->ack_incoming = vendor_qti_ims_sms_ack_incoming; + iface->add_report_handler = vendor_qti_ims_sms_add_report_handler; + iface->add_incoming_handler = vendor_qti_ims_sms_add_incoming_handler; + iface->remove_handler = vendor_qti_ims_sms_remove_handler; +} + + +BinderExtSms* vendor_qti_ims_sms_new(VendorQtiImsRadio* ims_radio,VendorQtiImsStateObject* ims_state){ + VendorQtiImsSms* sms= g_object_new(QTI_TYPE_SMS, NULL); + + sms->ims_state = ims_state; // 不是直接赋值 + sms->ims_radio = ims_radio; // 不是直接赋值 + // TODO绑定信号 qti-ims-radio-incoming-sms qti-ims-radio-sms-status-report + + return BINDER_EXT_IMS(sms); +} \ No newline at end of file diff --git a/src/vendor_qti_plugin.c b/src/vendor_qti_plugin.c new file mode 100644 index 0000000..04ea330 --- /dev/null +++ b/src/vendor_qti_plugin.c @@ -0,0 +1,97 @@ + +#include "plugin.h" +#include "binder_ext_ims.h" +#include "binder_ext_plugin_impl.h" +#include "binder_ext_slot_impl.h" + +/*==========================================================================* + * QTI plugin + *==========================================================================*/ + +typedef BinderExtPluginClass VendorQtiExtClass; +typedef struct qti_plugin { + BinderExtPlugin parent; + void* b_40; + int num; + +} VendorQtiExt; + +G_DEFINE_TYPE(VendorQtiExt, qti_plugin, BINDER_EXT_TYPE_PLUGIN) + +#define QTI_TYPE_PLUGIN qti_plugin_get_type() +#define QTI_PLUGIN(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, \ + QTI_TYPE_PLUGIN, VendorQtiExt) + +static const char qti_plugin_name[] = "qti"; + +static +BinderExtSlot* +qti_plugin_new_slot( + BinderExtPlugin* plugin, + RadioInstance* radio, + GHashTable* params) +{ + VendorQtiSlot* slot = g_object_new(QTI_TYPE_SLOT, NULL); + VendorQtiExt* self = QTI_PLUGIN(plugin); + char* ims_radio_num = g_strdup_printf("imsradio%d", self->num); + // + VendorQtiImsRadio* ims_radio = vendor_qti_ims_radio_new(self->b_40,ims_radio_num,2); + slot->ims_radio = ims_radio; + if(ims_radio != NULL){ + VendorQtiImsStateObject* ims_state = vendor_qti_ims_state_new(ims_radio); + slot->ims_state = ims_state; + slot->ims = vendor_qti_ims_new(ims_radio,ims_state); + slot->ims_call = vendor_qti_ims_call_new(slot->ims_radio,slot->ims_state); + slot->ims_sms = vendor_qti_ims_sms_new(slot->ims_radio,slot->ims_state); + } + g_free(ims_radio_num); + return slot; +} + +static +void +qti_plugin_init( + VendorQtiExt* self) +{ +} + +static +void +qti_plugin_class_init( + VendorQtiExtClass* klass) +{ + klass->plugin_name = qti_plugin_name; + klass->new_slot = qti_plugin_new_slot; +} + + + +// sub_B940 +static int vendor_qti_plugin_init(void){ + + BinderExtPlugin* plugin = g_object_new(QTI_TYPE_PLUGIN, NULL); + + binder_ext_plugin_register(plugin); + binder_ext_plugin_unref(plugin); + return 0; +} +// sub_B8F8 +static void vendor_qti_plugin_exit(void){ + +} + +OFONO_PLUGIN_DEFINE(vendor_qti, "Vendor QTI plugin", "1.28", + OFONO_PLUGIN_PRIORITY_DEFAULT, vendor_qti_plugin_init, vendor_qti_plugin_exit) + +/** + * VendorQtiExt + * VendorQtiIms + * VendorQtiImsCall + * VendorQtiImsConfObject + * VendorQtiImsRadio + * VendorQtiImsSms + * VendorQtiImsStateObject + * VendorQtiSlot + * + * + * */ \ No newline at end of file diff --git a/src/vendor_qti_slot.c b/src/vendor_qti_slot.c new file mode 100644 index 0000000..f2e2f06 --- /dev/null +++ b/src/vendor_qti_slot.c @@ -0,0 +1,64 @@ + +#include "plugin.h" +#include "binder_ext_ims.h" +#include "binder_ext_slot_impl.h" + + +/*==========================================================================* + * QTI slot + *==========================================================================*/ + +typedef BinderExtSlotClass VendorQtiSlotClass; +typedef struct qti_slot { + BinderExtSlot parent; + int* shutdown; + VendorQtiIms* ims;// 4 + VendorQtiImsSms* ims_sms;// 5 + VendorQtiImsCall* ims_call;// 6 + VendorQtiImsRadio* ims_radio;// 7 + VendorQtiImsStateObject* ims_state; // 8 +} VendorQtiSlot; + +G_DEFINE_TYPE(VendorQtiSlot, qti_slot, BINDER_EXT_TYPE_SLOT) + +#define QTI_TYPE_SLOT qti_slot_get_type() +#define QTI_SLOT(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, QTI_TYPE_SLOT, VendorQtiSlot) +#define QTI_IS_SLOT(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, QTI_TYPE_SLOT) + +static +gpointer +qti_slot_get_interface( + BinderExtSlot* slot, + GType iface) +{ + return BINDER_EXT_SLOT_CLASS(qti_slot_parent_class)-> + get_interface(slot, iface); +} + +static +void +qti_slot_shutdown( + BinderExtSlot* slot) +{ + VendorQtiSlot* self = QTI_SLOT(slot); + + if (self->shutdown) { + (*self->shutdown)++; + } + BINDER_EXT_SLOT_CLASS(qti_slot_parent_class)->shutdown(slot); +} +static +void +qti_slot_init( + VendorQtiSlot* self) +{ +} + +static +void +qti_slot_class_init( + VendorQtiSlotClass* klass) +{ + klass->get_interface = qti_slot_get_interface; + klass->shutdown = qti_slot_shutdown; +} \ No newline at end of file diff --git a/src/vendor_qti_util.c b/src/vendor_qti_util.c new file mode 100644 index 0000000..af08036 --- /dev/null +++ b/src/vendor_qti_util.c @@ -0,0 +1,2 @@ + +vendor_qti_util_markup_parse