Add support for Qualcomm's device. #174

Merged
merged 6 commits into from Apr 29, 2015

Conversation

Projects
None yet
3 participants
Contributor

peat-psuwit commented Apr 3, 2015

This add some essential code for oFono to work with LG L90 Dual (and maybe other Qualcomm's multi-sim device) correctly. This code cannot utilize 2nd sim slot yet.

Contributor

tonyespy commented Apr 5, 2015

Thanks for the pull-request. It's a reasonably well thought out approach.

That said, I have a couple of global comments, as well as some comments on the code itself.

First, our ofono rilmodem code is currently based on AOSP 4.4.2, whereas as some of the new RIL requests added by this pull-request, including the critical SET_UICC_SUBSCRIPTION request have been introduced in AOSP 5. As such, I wonder if it's worth adding a device plugin ( see plugins/mtk.c ), and using a vendor quirk for set subscription behavior, as it will fail on devices running an rild < 5. Using this approach would also allow you to start to build proper support for your device's dual-modem support.

Second, could you please re-format your commit messages to use prefixes ( eg. "include:", "gril:", ... ). Please take a look at some of the existing commits in our repository.

gril/ril_constants.h
@@ -372,6 +372,17 @@
#define RIL_REQUEST_VOICE_RADIO_TECH 108
#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
+#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
+#define RIL_REQUEST_IMS_SEND_SMS 113
+#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114
@tonyespy

tonyespy Apr 5, 2015

Contributor

GET_DATA_CALL_PROFILE doesn't appear to be a standard request defined by any version of AOSP's ril.h header. If it's a custom OEM request, then it should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave it out of this change.

gril/ril_constants.h
+#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
+#define RIL_REQUEST_IMS_SEND_SMS 113
+#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114
+#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 115
@tonyespy

tonyespy Apr 5, 2015

Contributor

This is only defined in AOSP v5. See my global comment about this. It also might be a good idea to add a comment indicating this ( either RIL version or AOSP version ).

@alfonsosanchezbeato

alfonsosanchezbeato Apr 6, 2015

Contributor

Note also that in lollipop the number for this request is 122. See:
http://androidxref.com/5.1.0_r1/xref/hardware/ril/include/telephony/ril.h

gril/ril_constants.h
+#define RIL_REQUEST_GET_DATA_CALL_PROFILE 114
+#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 115
+#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 116
+#define RIL_REQUEST_SIM_TRANSMIT_BASIC 117
@tonyespy

tonyespy Apr 5, 2015

Contributor

Neither SET_DATA_SUBS or SIM_TRANSMIT_BASIC appear to be standard requests defined by any version of AOSP's ril.h header. If they are custom OEM requests, then they should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave them out of this change.

gril/ril_constants.h
+#define RIL_REQUEST_SET_DATA_SUBSCRIPTION 116
+#define RIL_REQUEST_SIM_TRANSMIT_BASIC 117
+#define RIL_REQUEST_SIM_OPEN_CHANNEL 118
+#define RIL_REQUEST_SIM_CLOSE_CHANNEL 119
@tonyespy

tonyespy Apr 5, 2015

Contributor

SIM_OPEN_CHANNEL and SIM_CLOSE_CHANNEL are only defined in AOSP v5. See my global comment about this. It also might be a good idea to add comments indicating this ( either RIL version or AOSP version ).

gril/ril_constants.h
+#define RIL_REQUEST_SIM_OPEN_CHANNEL 118
+#define RIL_REQUEST_SIM_CLOSE_CHANNEL 119
+#define RIL_REQUEST_SIM_TRANSMIT_CHANNEL 120
+#define RIL_REQUEST_SIM_GET_ATR 121
@tonyespy

tonyespy Apr 5, 2015

Contributor

Neither SIM_TRANSMIT_CHANNEL or SIM_GET_ATR appear to be standard requests defined by any version of AOSP's ril.h header. If they are custom OEM requests, then they should be added in an OEM-specific header. Also, as it's not used in any of your new code, I would just leave them out of this change.

drivers/rilmodem/sim.c
+ selected_app = i;
+ }
+ }
+ else {
@tonyespy

tonyespy Apr 5, 2015

Contributor

The closing brace should be on the same line as the 'else'. Ex.

} else {

drivers/rilmodem/sim.c
+ * So, we need to figure out which app to use
+ * and send that request out.
+ */
+ search_index = sim_select_uicc_subscription(sim, status);
@tonyespy

tonyespy Apr 5, 2015

Contributor

Since -1 is still a possible return value from sim_select_uicc_subscription(), it still can be used an array index, which leads to undefined behavior. We should catch this, log it as an error, and not allow it to be used.

drivers/rilmodem/sim.c
+ case RIL_APPTYPE_RUIM:
+ break;
+ default:
+ selected_app = i;
@tonyespy

tonyespy Apr 5, 2015

Contributor

First, shouldn't this be RIL_APPTYPE_SIM | USIM? RUIM is used by CDMA phone.

I'm also not sure why you're check app_type twice or why you'd set selected_app in the default case of the second check?

@peat-psuwit

peat-psuwit Apr 6, 2015

Contributor

This is algorithm used in CM [1]. It prefers USIM | RUIM over SIM | CSIM. (That second app_type check replaces selected_app with current one if current selected_app isn't USIM | RUIM) As there isn't CDMA support in oFono yet, it may be make sense to just log that and skip that app.
[1] https://github.com/CyanogenMod/android_frameworks_opt_telephony-msim/blob/cm-11.0/frameworks/src/com/codeaurora/telephony/msim/SubscriptionManager.java#L401-L450

Contributor

alfonsosanchezbeato commented Apr 6, 2015

A few additional comments on my side:

  • As Tony said, some of the requests you have added are not really from AOSP, but Qualcomm-specific. Even more, I have taken a look at latest ril.h in codeaurora (=Qualcomm Android), and those requests are there, but the numbers have changed, probably because they are taking new AOSP requests and they displace theirs when needed. See:
    https://www.codeaurora.org/cgit/quic/la/platform/hardware/ril/tree/include/telephony/ril.h?h=LA.BF64.1.2.1_rb2.7
    So the changes can be said to be specific to your concrete device. The best thing to in this case is to define a vendor specific quirk, say OFONO_RIL_VENDOR_LG_L90_DUAL, and add it to drivers/rilmodem/vendor.h. You need to define then a plugin for your modem, which in this case will be fairly easy as you can use all functions from the ril plugin (you can use plugins/infineon.c as an example).
    One or another driver is loaded depending on environment variables: see plugins/rildev.c and /etc/init/ofono.override and /etc/init/rild.conf upstart jobs on the phone). You can define the requests in a similar way to drivers/infineonmodem/infineon_constants.h or drivers/mtkmodem/mtk_constants.h. And after that you can use a quirk in drivers/rilmodem/sim.c so you send SET_UICC_SUBSCRIPTION only when your plugin is the one being used.
  • Do you have a pointer to the ril.h you used for defining the constants? Just curious :-)
  • Please take a look to doc/coding-style.txt and format your PR accordingly. oFono uses the kernel coding guidelines as base, for instance: use tabs, tabs == 8 whitespaces, line length < 80, etc.
Contributor

peat-psuwit commented Apr 6, 2015

For ril.h constants, I just copy them from CM 11's version of ril.h, as that works for my device. I though it's some update from somewhere so it seemed to make sense to include them all. But, as you point out, it may be more appropriate to just include the needed constants only.

Contributor

alfonsosanchezbeato commented Apr 7, 2015

Just for the record, latest HEAD in CM repo defines

#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122

(as in AOSP) so as a minimum, using 115 instead of 122 must be a vendor quirk. Note also that most commits to CM's ril.h come from codeaurora guys.

Contributor

peat-psuwit commented Apr 11, 2015

Ok, then it's probably Qualcomm's quirk in Android 4.4. But if I move the constant to modem-specific header, then where should I put the g_ril_set_uicc_subscription function?

BTW, how should I change the code and re-submit? New pull request?

Contributor

alfonsosanchezbeato commented Apr 13, 2015

It is fine to implement g_ril_set_uicc_subscription in gril as it is defined by AOSP 5. However, the constant used for the request in g_ril_send should be defined as vendor-specific in a similar way as the constants in mtk_constants.h. And when using it in rilmodem/sim.c you should check the vendor.

You can rebase and resubmit this PR or use a new one, whatever which is easier for you.

Contributor

peat-psuwit commented Apr 13, 2015

Resubmit this PR? You mean force-pushing new commit into this branch?

Contributor

alfonsosanchezbeato commented Apr 14, 2015

@peat-psuwit yes, I normally do a "git rebase -i" to have a clean history and then a forced push when re-submitting. But, again, whatever works best for you. You can close this PR and create a new one if you prefer.

Contributor

peat-psuwit commented Apr 14, 2015

Ok, new version is pushed. I hope I does it right.

+ *
+ * RIL constants for Qualcomm multi-sim modem
+ *
+ * Copyright (C) 2014 Canonical Ltd.
@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

You created this file so you can (C) it yourself

drivers/rilmodem/sim.c
+ g_ril_request_set_uicc_subscription(sd->ril, slot_id, app_index,
+ sub_id, sub_status, &rilp);
+ g_ril_send(sd->ril, QCOM_MSIM_RIL_REQUEST_SET_UICC_SUBSCRIPTION, &rilp,
+ NULL, NULL, NULL);
@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

I would add here a callback function to check for message->error and call g_ril_print_response_no_args() (see for instance mtkmodem/voicecall.c:mtk_set_indication_cb()), so we know when the call failed.

drivers/rilmodem/sim.c
@@ -640,6 +641,59 @@ static void configure_active_app(struct sim_data *sd,
}
}
+static void sim_send_set_uicc_subscription(struct ofono_sim *sim, int slot_id, int app_index, int sub_id, int sub_status)
drivers/rilmodem/sim.c
*/
- __ofono_sim_recheck_pin(sim);
+ search_index = sim_select_uicc_subscription(sim, status);
@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

You probably need to send SET_UICC_SUBSCRIPTION only once, not after each SIM_STATUS request. I think you could check sim_data::app_index to see if it is initialized or not (it is set by configure_active_app()). You would need to initialize that variable to -1 when sim_data is created.

@peat-psuwit

peat-psuwit Apr 15, 2015

Contributor

I only send that request if search_index is -1 (actually UINT_MAX, which is more than num_apps), not every time the SIM status is replied.

@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

Ok, you are right, the modem should send a value different to -1 once the application is selected.

@peat-psuwit

peat-psuwit Apr 23, 2015

Contributor

@tonyespy this line is 2 characters longer then 80 characters. I'm not sure how to cut the word?

@tonyespy

tonyespy Apr 23, 2015

Contributor

It's actually only one character over 80, as the trailing line breaks aren't counted.

Take a look at the doc/coding-style.txt, as it has some examples of how this could be corrected.

The simplest would be to just wrap the 2nd parameter:

               search_index = sim_select_uicc_subscription(sim,
                                                             status);

Note - all tabs are used, this puts the wrapped link just at the 80 char limit.

Or, you could wrap after the "=", like this:

                    search_index =
                            sim_select_uicc_subscription(sim, status);

But I think the first is preferable.

gril/grilrequest.h
+ int sub_status,
+ struct parcel *rilp);
+
+
@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

No double empty lines, please

drivers/rilmodem/sim.c
- if (app->app_type != RIL_APPTYPE_UNKNOWN) {
- configure_active_app(sd, app, search_index);
- DBG("passwd_state: %d", sd->passwd_state);
+ __func__, status->card_state);
@alfonsosanchezbeato

alfonsosanchezbeato Apr 15, 2015

Contributor

ofono uses only tabs for indenting

plugins/qcom-msim.c
+}
+
+OFONO_PLUGIN_DEFINE(qcom_msim, "Modem driver for Qualcomm's multi-sim device",
+ VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT, qcom_msim_init, qcom_msim_exit)
Contributor

alfonsosanchezbeato commented Apr 15, 2015

Overall, looks pretty good to me. @tonyespy ?

Contributor

peat-psuwit commented Apr 17, 2015

New version updated with @alfonsosanchezbeato suggestion and rebased to current master.

Contributor

tonyespy commented Apr 20, 2015

So this looks pretty good to me, although I have a couple of comments:

  1. The copyright for plugins/qcom-msim.c is 'Copyright 2014 Canonical', and should be '2015 Ratchanan Srirattanamet' instead.

  2. I would also probably add additional copyright statements to rilmodem/sim.c and grilrequest.c.

  3. I'm not sure I like the last commit, which says in the commit message "This assumes that Qualcomm's multi-sim device behave similar to AOSP device". Can't this be tested and the assumption confirmed?

Contributor

peat-psuwit commented Apr 21, 2015

I'll edit copyright for plugins/qcom-msim.c as you suggest. But I'm not so sure if I can add a copyright statement on my rilmodem/sim.c and grilrequest.c's addition. (Isn't there some kind of CLA?)

For the last commit, I forgot to test that because I don't have PIN locking enabled. Let me test that and I'll edit the commit message in the next patchset.

Contributor

tonyespy commented Apr 21, 2015

I'll double check with Alfonso re: the copyright. AFAIK, there is no CLA for ofono. I think the general rule of thumb is whether or not the patch is considered significant or not.

Also please do test the last commit. We don't like to merge code based on assumptions...

Contributor

peat-psuwit commented Apr 21, 2015

OK, after a simple checking with my phone with this patch, PIN locking seems to work fine. So I'll definitely edit the commit message. But to reduce clutter on this pull request, I'll wait until I have clarity about copyright, and will re-submit these commit again.

Contributor

tonyespy commented Apr 21, 2015

There is no CLA, and the change you've submitted is complex enough to warrant an additional copyright statement if you want to add it, but I think the choice is yours.

Contributor

peat-psuwit commented Apr 22, 2015

Ok, new version uploaded. Copyright statement is added. PIN handling's commit is edited. And the commit is rebased to the new master.

drivers/rilmodem/sim.c
+ * again. An option that can be explored in the
+ * future is wait before invoking core callback
+ * for send_passwd until we know the real password state.
+ */
@tonyespy

tonyespy Apr 22, 2015

Contributor

I hate to reject this again, but as I was doing a final review I noticed that some of these comments had been moved inside of this if block, and noticed that some of the lines are pretty long, so I checked... And at least fives lines in the first comment, and two in the next comment are all over 80 characters long. Sorry to be a stickler, but we try to stick to the coding style doc ( see /doc/coding-style.txt ).

@peat-psuwit

peat-psuwit Apr 23, 2015

Contributor

As they are indented a lot, I tough they seem to look better when they're a few characters longer. But if that's matter, I'll try to do the word cutting again.

@tonyespy

tonyespy Apr 23, 2015

Contributor

Well, the comments had been left in their original position, this wouldn't have been a problem.

The style guide says it's OK to exceed if it makes the code really ugly otherwise, but as we're talking about comment here, these should be fixed.

peat-psuwit added some commits Apr 13, 2015

plugins: add qcom_msim plugin.
This plugin handles quirks in Qualcomm's implementation of multi-sim
modem.
gril: Adding vendor in PIN retries handling.
Qualcomm multi-sim device's seems to behave in the same way as
AOSP device. This add QCOM_MSIM case under AOSP case to use
the same code.
rilmodem: Adding code to send SET_UICC_SUBSCRIPTION
On Qualcomm's multi SIM device, all index for apps in sim_status_cb will
be -1 (but will wrap up to UINT_MAX because index is uint) until we send
RIL_REQUEST_SET_UICC_SUBSCRIPTION. So, we need to figure out which app
to use and send that request out.
Contributor

alfonsosanchezbeato commented Apr 29, 2015

LGTM. @peat-psuwit, thanks a lot for the patch and for your patience while following the review process

alfonsosanchezbeato added a commit that referenced this pull request Apr 29, 2015

Merge pull request #174 from peat-psuwit/lg-d410-merge
Add support for Qualcomm's device.

@alfonsosanchezbeato alfonsosanchezbeato merged commit 4e62e5f into rilmodem:master Apr 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment